I wanted to get a list of all webs within a web application. By accident I wrote the following:

$webapp = "http://mywebapp"
$webapp | Get-SPSite | Get-SPWeb

So, this returned fantastic results, giving me the URLs of each web in the web app. But the powershell command doesn't make sense to me.

I actually meant to write something like:

$webapp = "http://mywebapp"
Get-SPWebApplication $webapp | Get-SPSite | Get-SPWeb

which produces the same results. Does it just take the url at face value and intelligently assume it's a web app url? I'm guessing it converts it to an SPWebApplication object, and pipes that to Get-SPSite, which gets each site collection object within the web app, etc..

1 Answer 1


The pipeline passes one object of a command to another. The result of the first command is an input for the next command.

So in your example The first command Generated List of SPWebApplication which is passed to Get-SPSite etc



From the technet article of Get-SPSite - The Get-SPSite cmdlet returns either a single site that matches the Identity parameter, or all the sites that match the Filter parameter for the specified scope. The scopes are the WebApplication, ContentDatabase , and SiteSubscription parameters. If none of these scopes is provided, the scope is the farm. If the scope is specified with no Filter parameter, all sites in that scope are returned.

So it can be piped from SPWebApplication, SPContentDatabase, and SPSiteSubscription

Get-SPContentDatabase | Get-SPSite
  • So this is my confusion: there are multiple input parameters for SPSite that can take "URL". How does the piped SPSite know whether I am specifying for SPSite's -WebApplication parameter instead of the -Identity parameter?
    – ferr
    Nov 26, 2014 at 15:15
  • I think what would help is if technet's definitions had a "piped inputs" section. If I change the $webapp value to something that doesn't exist ie "mywebapp/nothing_here" it throws an error that it cannot find a web application at that url. This means to me that it expects a web application url, of course. This needs to be documented somehow in the SPSite article.
    – ferr
    Nov 26, 2014 at 15:18
  • @ferr I have updated my answer Nov 26, 2014 at 15:29
  • ah! thank you. i saw that, but I wasn't sure if it was what I was looking for since it did not really define what it meant by "Filter parameter". It appears that is what I meant by "Piped Inputs".
    – ferr
    Nov 26, 2014 at 15:31
  • Actually reading it again, it's not the filter parameter, but the "scopes". Is that a universal term used throughout powershell? I would like it if I could find "Scopes" listed on each object's technet article... for example if you look at the Get-SPWeb article there is no mention of scopes nor any information about what to pipe to it.
    – ferr
    Nov 26, 2014 at 15:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.