1.2. Understanding Properties and Methods
Everything that SharePoint knows about an object is stored in data elements and values known as properties,
which also describe the state of that object. For example, the
SPContentDatabase object contains all the information about the content
databases within the farm.
Objects not only have
properties, they also contain actions that determine how they can be
manipulated. In object-oriented terminology, these actions, or
different ways of acting on an object, are called methods. To determine the properties and methods for the SPSite object, use the cmdlets in the following example, where a portion of the output is shown.
PS C:\Users\peter> Get-SPSite | Get-Member
Name MemberType Definition
---- ---------- ----------
AddWorkItem Method System.Guid AddWorkItem(Sys...
BypassUseRemoteApis Method System.Void BypassUseRemote...
CheckForPermissions Method System.Void CheckForPermiss...
Close Method System.Void Close()
ConfirmUsage Method bool ConfirmUsage()
Delete Method System.Void Delete(), Syste...
Dispose Method System.Void Dispose()
ToString Method string ToString()
UpdateValidationKey Method System.Void UpdateValidatio...
VisualUpgradeWebs Method System.Void VisualUpgradeWe...
AdministrationSiteType Property Microsoft.SharePoint.SPAdmi...
AllowDesigner Property System.Boolean AllowDesigne...
AllowMasterPageEditing Property System.Boolean AllowMasterP...
....(not all output shown)
WarningNotificationSent Property System.Boolean WarningNotif...
WebApplication Property Microsoft.SharePoint.Admini...
WorkflowManager Property Microsoft.SharePoint.Workfl...
WriteLocked Property System.Boolean WriteLocked ...
Zone Property Microsoft.SharePoint.Admini...
BEST PRACTICE Never miss an opportunity to pipe the Get-SP<noun> cmdlet to the Get-Member cmdlet. It is sometimes surprising what information an object is able to retrieve.
If you want to find all the site collections in the farm, you can type Get-SPSite.
However, the only output you will see is the URL of the site
collections. For performance reasons, the Url property is the only
property displayed by default. This is because site collections have
many properties; if you display all of these properties for a large
number of site collections, you will consume a large amount of memory,
and the command will take a long time to run. Displaying just the Url
property is almost instantaneous because it is cached. Therefore, you
should refrain from running this command to display more than a few
To display more than the
default property, you can use the select Windows PowerShell cmdlet with
the pipe (|) character. You also can use the wildcard character (*)
with the select statement to list all the property values, as shown in
the following example.
PS C:\Users\Peter> Get-SPSite "http://teams" | select *
ApplicationRightsMask : FullMask
ID : cbf3290e-000e-4768-953c-99a983430283
SystemAccount : SHAREPOINT\system
Owner : CONTOSO\spadmin
SecondaryContact : CONTOSO\peter
GlobalPermMask : FullMask
IISAllowsAnonymous : False
Protocol : http:
HostHeaderIsSiteName : False
HostName : teams
Port : 80
...(not all output shown)
AllowDesigner : True
AllowRevertFromTemplate : False
AllowMasterPageEditing : False
ShowURLStructure : False
To get a list of all site
collections in your farm, together with the name of the content
database where they are stored (output that gives only the URL of the
site collection and the content database name), you would use the
commands as shown in the following example, which also shows the sample
PS C:\Users\peter> Get-SPSite | select url, contentdatabase
http://MySite SPContentDatabase Name=Contoso_MySiteDB
http://MySite/personal/peter SPContentDatabase Name=Contoso_PersonalDB
http://MySite/personal/erin SPContentDatabase Name=Contoso_PersonalDB
http://intranet.contoso.msft SPContentDatabase Name=Contoso_IntranetDB
http://teams SPContentDatabase Name=Contoso_TeamsDB
http://teams/sites/Finance SPContentDatabase Name=Contoso_TeamsDB