Programming4us
         
 
 
Sharepoint

Working with the SharePoint 2010 Management Shell (part 4) - Understanding Properties and Methods

12/13/2010 2:44:36 PM
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


   TypeName: Microsoft.SharePoint.SPSite
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...



Note:

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.


Real World: Performance Issues When Running Windows PowerShell Commands

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 additional properties.


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 output.

PS C:\Users\peter> Get-SPSite | select url, contentdatabase


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

Other -----------------
- SharePoint 2010 : Edit the Contents of a Page
- SharePoint 2010 : Change the Page Layout of a Publishing Page
- SharePoint 2010 : Authoring Pages - Edit the Properties of a Page
- SharePoint 2010 : Authoring Pages - Create a New Page (part 2)
- SharePoint 2010 : Authoring Pages - Create a New Page (part 1)
- SharePoint 2010 : Managing Systems Remotely with WinRM
- SharePoint 2010 : Installing Windows PowerShell
- SharePoint 2010 : Using Windows PowerShell: The Basics
- SharePoint 2010 : Modify a View
- SharePoint 2010 : Create Mobile Views
- Uninstalling SharePoint 2010
- Configuring a SharePoint 2010 Installation (part 1) - Renaming the Central Administration Database
- Configuring a SharePoint 2010 Installation (part 1) - Running the Farm Configuration Wizard
- SharePoint 2010 : Enable or Disable Inline Editing in a View
- Performing SharePoint 2010 Installations (part 5)
- Performing SharePoint 2010 Installations (part 4)
- Performing SharePoint 2010 Installations (part 3)
- Performing SharePoint 2010 Installations (part 2)
- Performing SharePoint 2010 Installations (part 1) - SharePoint 2010 Standalone Installation
- SharePoint 2010 : Specify the Item Limit for a View
 
 
Most View
- Programming Windows Azure : Table Operations - Creating Entities
- What is New in iPhone SDK 3.2 for the iPad (part 2)
- BizTalk Server 2009 : Getting results from asynchronous invocations (part 1) - Building WCF services that support client callbacks
- Microsoft Dynamics AX 2009 : The Application Integration Framework (part 4) - Working with Document Services - Customizing Document Services
- BizTalk Server 2009 : The core principles of a service-oriented architecture (part 4)
- Encryption Catalog Views
- Troubleshooting Windows Home Server 2011 : Replacing Your System Hard Drive
- Active Directory Domain Services 2008: Create Password Settings Objects
- Windows 7 : Useful Windows 7 Logon Strategies
- Microsoft Systems Management Server 2003 : Systems Management Server Installer Tools & Creating Installation Scripts
Top 10
- Implementing Edge Services for an Exchange Server 2007 Environment : Utilizing the Basic Sender and Recipient Connection Filters (part 3) - Configuring Recipient Filtering
- Implementing Edge Services for an Exchange Server 2007 Environment : Utilizing the Basic Sender and Recipient Connection Filters (part 2)
- Implementing Edge Services for an Exchange Server 2007 Environment : Utilizing the Basic Sender and Recipient Connection Filters (part 1)
- Implementing Edge Services for an Exchange Server 2007 Environment : Installing and Configuring the Edge Transport Server Components
- What's New in SharePoint 2013 (part 7) - BCS
- What's New in SharePoint 2013 (part 6) - SEARCH
- What's New in SharePoint 2013 (part 6) - WEB CONTENT MANAGEMENT
- What's New in SharePoint 2013 (part 5) - ENTERPRISE CONTENT MANAGEMENT
- What's New in SharePoint 2013 (part 4) - WORKFLOWS
- What's New in SharePoint 2013 (part 3) - REMOTE EVENTS