Datasheet

28 CHAPTER 1
WINDOWS POWERSHELL 101
Name MemberType Definition
---- ---------- ----------
Equals Method bool Equals(System...
GetHashCode Method int GetHashCode()
GetType Method type GetType()
LookupName Method string LookupName()
ToString Method string ToString()
ValidateLogonAccount Method System.Void Valida...
SecurityIdentifier Property System.Security.Pr...
Name ScriptProperty System.Object Name...
Notice that the
Name
property is of type
ScriptProperty
. If you look up the
SPProcessAccount
type in the SDK, you should note that it does not include a
Name
property.  is property is added dynamically by Windows PowerShell when it loads a
special  le called a type formatter  le. ese les, and their creation and use, are out-
side the scope of this book. However, the key thing to take away is that some objects
will have “enhancements” to them that go beyond what is provided by the core type.
Declare and Use Arrays and Hash Tables
O entimes, when working with Windows PowerShell, there will be a need to create a
collection of data that can be used for input to various cmdlets. Windows PowerShell
makes it extremely easy to create these collections in the form of either an array or a
hash table. An array is essentially just a list of items that can be indexed using their
position in the list, where the  rst item is at index zero. Hash tables are a collection of
name-value pairs that can be indexed using the name of the item.
To create an array in Windows PowerShell, simply wrap the comma-separated items
in parentheses preceded by an
@
symbol:
PS C:\> $siteUrls = @(“http://portal”, “http://teams”)
PS C:\> $siteUrls
http://portal
http://teams
PS C:\>
To access an item within the array, add the index of the item surrounded by square
brackets to the end of the variable name:
PS C:\> $siteUrls[1]
http://teams
PS C:\>
c01.indd 28c01.indd 28 5/16/2011 11:12:34 AM5/16/2011 11:12:34 AM