Datasheet

32 CHAPTER 1
WINDOWS POWERSHELL 101
-useremail someone@example.com
-username “Your Name”
stsadm.exe -o enumusers -url http://server/site/web
e concept of passing data from one command to another is known as piping.  e
Windows PowerShell pipeline facilitates this movement of data between commands.
The Object Pipeline
Windows PowerShell not only includes this capability, it extends it greatly in that
cmdlets are more aware of the pipeline and can make intelligent decisions about
how to use the passed-in data based on the data type.  ink of the pipeline as an
assembly line where each stage performs some sort of operation and then passes the
results of that operation to the next stage.
Consider the following example that uses the
Get-SPWeb
cmdlet and then “pipes”
the resultant
SPWeb
objects to the
Where-Object
cmdlet to  lter the results to just
those that use the new
v4.master
master page:
PS C:\> Get-SPWeb http://portal/* | where {$_.MasterUrli
-like “*/v4.master”}
Url
---
http://portal
http://portal/SiteDirectory
http://portal/SearchCenter
http://portal/News
http://portal/Docs
is code passes in a wildcard-based URL to the
Get-SPWeb
cmdlet to return back
all
SPWeb
objects under the
http://portal/
web application, and then it passes
those objects to the
Where-Object
cmdlet. (Notice how this example uses the
where
alias rather than the full name of the cmdlet.)  e variable
$_
represents the
current object within the script block. (Filtering and iterating are discussed in more
detail in Chapter 2, “Filtering and Iterating Your Data.”)
e easiest way to determine what data can be piped into a cmdlet is to get help for
the cmdlet and look at the description of the various parameters. Execute
help
Get-SPWeb -full
to display the following parameter descriptions (among others):
PARAMETERS
-Identity <SPWebPipeBind>
Specifies the name or full or partial URL of the subsit
c01.indd 32c01.indd 32 5/16/2011 11:12:34 AM5/16/2011 11:12:34 AM