The main reason I began writing my PowerShell extensions was that I needed to do some in-depth traversal of the SharePoint farm and its content. I’m going to demonstrate some of those extensions now, using
Getting an SPWeb
The conventional way of obtaining a reference to an SPWeb is:
get-spweb http://mybiglongservername:8080/path/to/web
Because this requires a fully-qualified URL, it gets when dealing with a lot of sites and webs. Sometimes I’ll just throw the web in a variable, but that’s not exactly good practice because it can lead to memory leaks. Instead, I wrote Get-SPWebRelative, which can be used like this:
get-spwebrelative /path/to/web
You can even get the root web:
get-spwebrelative /
Similarly, there is a Get-SPSiteRelative function that works the same way.
Discussion
No comments for “SharePoint Extension: Get-SPWebRelative”
Post a comment