Datasheet

PREPARE FOR YOUR JOURNEY 5
Getting Started with
Windows PowerShell
Basics
PART 1
Before you dig deep into Windows PowerShell, it is a good idea to take a look at
the other scripting options available to you, speci cally STSADM and PSCon g,
the command-line version of the SharePoint Con guration Wizard.  is is use-
ful because there are some tasks that can only be accomplished using STSADM
(though not many).
Automate SharePoint: A Historical Perspective
When SharePoint 2003 was introduced, Microso made available the  rst ver-
sion of STSADM.  is allowed administrators to automate some common tasks
related to the day-to-day management and deployment activities of SharePoint.
Unfortunately, the tool was very limited in scope and not extensible. With
SharePoint 2007, Microso introduced numerous new commands (over 184 in
total) and adapted the architecture of the tool so that third-party developers could
extend it by adding new commands.  is provided a consistent and uniform
administrative experience.
Administrators (and developers) would very o en create batch  les that would call
out to these various STSADM commands. Unfortunately, batch  les provided lim-
ited support for looping and conditional expressions, so it was common for batch
les to become very complex and error-prone.
e following is a simpli ed version of a snippet from a SharePoint 2007 Farm
creation script:
ECHO %DATE% %TIME%: Building configuration database
psconfig -cmd configdb -create -server %SERVER_DB% i
-database %DB_CONFIG_NAME% -user %ACCT_SPFARM% i
-password %ACCT_SPFARM_PWD% -admincontentdatabase i
%DB_CENTRALADMINCONTENT_NAME%
if not errorlevel 0 goto errhnd
ECHO %DATE% %TIME%: Installing help content
psconfig -cmd helpcollections -installall
if not errorlevel 0 goto errhnd
ECHO %DATE% %TIME%: Securing resources
psconfig -cmd secureresources
if not errorlevel 0 goto errhnd
ECHO %DATE% %TIME%: Installing services
c01.indd 5c01.indd 5 5/16/2011 11:12:30 AM5/16/2011 11:12:30 AM