Datasheet
22 CHAPTER 1
•
WINDOWS POWERSHELL 101
While these names will work in Windows PowerShell, it is more common to see
variables expressed using camel case. Camel case is a naming convention that has
the rst word lowercased and the rst letter of each additional word capitalized. e
preceding example would look like the following:
PS C:\> $sharePointSiteName = “Home”
PS C:\> $contentDatabase = “WSS_Content”
COMBINING STATEMENTS
You can combine Windows PowerShell statements on the same line by using the semi-
colon. If you are coming from a development language similar to C# or Java, then this
concept will be easy to grasp. We will now combine the previous example into one line.
PS C:\> $sharePointSiteName = “Home”; $contentDatabase i
= “WSS_Content”
You can see the value of any variable by simply entering the variable name at the
console or by using the
Write-Output
cmdlet:
PS C:\> Write-Output $farm
Name Status
---- ------
SharePoint_ConfigDB Online
TIP
To see the list of variables that have been declared, use the
Get-Variable
cmdlet. To see more information about built-in (or automatic) variables, enter
help
about_automatic_variables
.
Understand Object Types
As previously stated, when you declare a variable or get data from a cmdlet, every-
thing you are creating, or retrieving, is a fully quali ed .NET object… and by
everything, we mean everything! Consider the following example:
PS C:\> “Tessa”.GetType()
IsPublic IsSerial Name BaseType
-------- -------- ---- --------
True True String System.Object
c01.indd 22c01.indd 22 5/16/2011 11:12:33 AM5/16/2011 11:12:33 AM