Datasheet

UNDERSTAND THE COMPONENTS 9
Getting Started with
Windows PowerShell
Basics
PART 1
C:\...\PowerShell.exe -NoExit “ & ‘ i
C:\...\14\CONFIG\POWERSHELL\Registration\sharepoint.ps1 ‘ “
e SharePoint 2010 Management Shell is just a Windows PowerShell instance that
loads the
sharepoint.ps1
script le. If you open this script  le, you will see the
following:
$ver = $host | select version
if ($ver.Version.Major -gt 1) {
$Host.Runspace.ThreadOptions = “ReuseThread”
}
Add-PsSnapin Microsoft.SharePoint.PowerShell
Set-location $home
# SIG # Begin signature block
# MIIXUAYJKoZIhvcNAQcCoIIXQTCCFz0CAQExCzA...
# SIG # End signature block
e line with the call to
Add-PsSnapin
is the most critical, and it is the only
one that matters right now. ( e implications of the previous lines are detailed
in Chapter 2, “Filtering and Iterating Your Data.”) Add-PsSnapin is a Windows
PowerShell cmdlet that is used to register a collection of new cmdlets that are
packaged in what is called a snap-in. When the SharePoint 2010 binaries are
installed, the assemblies that contain the SharePoint PowerShell cmdlets are also
installed and registered with the system. However, those assemblies, and the cmd-
lets de ned within them, will not be available to PowerShell until they are added
using the
Add-PsSnapin
cmdlet.
e signi cance of this is that you can easily work with the SharePoint PowerShell
cmdlets in editors other than the SharePoint Management Shell (or, speci cally, the
Windows PowerShell console window). In fact, our general recommendation is to
not use the SharePoint Management Shell and instead to use a script editor such
as the Windows PowerShell Integrated Scripting Environment (ISE) or a third-party
scripting editor.  e Windows PowerShell ISE is available only with PowerShell V2
and can be loaded by going to Start
All Programs
Accessories
Windows
PowerShell. By default, the Windows PowerShell ISE is not available on the Server
operating systems and must be added as an additional Feature before it will be
available.
If you choose to use the Windows PowerShell ISE, you must manually execute the
Add-PsSnapin Microsoft.SharePoint.PowerShell
command. However,
c01.indd 9c01.indd 9 5/16/2011 11:12:31 AM5/16/2011 11:12:31 AM