Use PowerShell to Get ManagedPaths in SharePoint 2010

Just a quick post here. I wanted to get a list of all Managed Paths in my SharePoint 2010 farm.

So I first saw

Get-SPManagedPath

Next, I found it’s parameters by using

get-help get-spmanagedpath

Note: If you use it without a parameter, it prompts you for the web app url. Kind of neat. The PowerShell ISE actually displays a dialog window, while the PS> cmd prompt asks for a parameter.

Knowing that I could get a list of web applications from somewhere, I found

get-spwebapplication

And then piping each webapplication’s “url” property to another commandlet will get me what I’d like. And that is a listing of all managed paths in my farm.

get-spwebapplication | foreach { Get-SPManagedPath -WebApplication $_.url }

From there, it was all playing with the script to save both the web application url and the managed path. Here’s what I came up with:

And here is the code if you need to copy and paste it.

clear-host
write-host "------ BEGIN -----"
write-host ""
Add-PSSnapin Microsoft.SharePoint.Powershell
$a = New-Object System.Collections.ArrayList
$webapps = get-spwebapplication
foreach ($webapp in $webapps)
{
    $paths = Get-SPManagedPath -WebApplication $webapp.url;
    foreach ($path in $paths)
    {
        $a.Add( $webapp.url + $path.name );
    }
}
#Write out the results if you need them
$a
write-host ""
write-host "------ END -----"

Next stop, creating a managed path with PowerShell.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: