{"id":794,"date":"2013-01-28T12:51:57","date_gmt":"2013-01-28T12:51:57","guid":{"rendered":"https:\/\/poiseddevelopers.com\/reality-tech\/?p=794"},"modified":"2024-04-26T12:50:44","modified_gmt":"2024-04-26T12:50:44","slug":"accessing-an-spitem-via-full-url","status":"publish","type":"post","link":"https:\/\/poiseddevelopers.com\/reality-tech\/accessing-an-spitem-via-full-url\/","title":{"rendered":"Accessing an SPItem via full URL"},"content":{"rendered":"<h4>Accessing an SPItem via full encoded URL<\/h4>\n<p>One of the most common tasks is to access a document; heck isn\u2019t that half of what SharePoint is about? Well in PowerShell it\u2019s actually not obvious how to do it. I\u2019ve used embarrassingly iterative hacks in the past, but my friend Brett Parker figured it out. Here\u2019s the solution:<\/p>\n<pre lang=\"php\">$docurl = \"http :\/\/SharePoint.com\/sites\/mySite\/myWeb\/myList\/SpecificFileName.xlsx\"\r\n$site = New-Object Microsoft.SharePoint.SPSite($docurl)\r\n$web = $site.OpenWeb()\r\n$item = $web.GetListItem($docurl)\r\n$list = $item.ParentList\r\n\r\n<\/pre>\n<p data-uw-rm-sr=\"\">$item now has the SPListItem, and you\u2019re good to go.<\/p>\n<p>Note that the SPDocumentLibrary is derived from the parentList property of the item.<\/p>\n<p data-uw-rm-sr=\"\">Interestingly, the $site.openWeb() doesn\u2019t open the RootWeb of the SPSite, but the actual web of the URL, which is great.<\/p>\n<pre lang=\"php\"><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Accessing an SPItem via full encoded URL One of the most common tasks is to access a document; heck isn\u2019t that half of what SharePoint is about? Well in PowerShell it\u2019s actually not obvious how to do it. I\u2019ve used embarrassingly iterative hacks in the past, but my friend Brett Parker figured it out. Here\u2019s [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":933,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[26],"tags":[],"class_list":["post-794","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-powershell"],"acf":[],"_links":{"self":[{"href":"https:\/\/poiseddevelopers.com\/reality-tech\/wp-json\/wp\/v2\/posts\/794","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/poiseddevelopers.com\/reality-tech\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/poiseddevelopers.com\/reality-tech\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/poiseddevelopers.com\/reality-tech\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/poiseddevelopers.com\/reality-tech\/wp-json\/wp\/v2\/comments?post=794"}],"version-history":[{"count":1,"href":"https:\/\/poiseddevelopers.com\/reality-tech\/wp-json\/wp\/v2\/posts\/794\/revisions"}],"predecessor-version":[{"id":796,"href":"https:\/\/poiseddevelopers.com\/reality-tech\/wp-json\/wp\/v2\/posts\/794\/revisions\/796"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/poiseddevelopers.com\/reality-tech\/wp-json\/wp\/v2\/media\/933"}],"wp:attachment":[{"href":"https:\/\/poiseddevelopers.com\/reality-tech\/wp-json\/wp\/v2\/media?parent=794"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/poiseddevelopers.com\/reality-tech\/wp-json\/wp\/v2\/categories?post=794"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/poiseddevelopers.com\/reality-tech\/wp-json\/wp\/v2\/tags?post=794"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}