As I mentioned in a previous article, SharePoint Server 2010 comes with 531 sharepoint-specific PowerShell cmdlets — little commands for sharepoint management — built in to the SharePoint 2010 Management Shell. Now, let’s take a quick survey of some of these cmdlets as well as some tips on how you can get up-to-speed with managing SharePoint with PowerShell.
Like all PowerShell cmdlets, these little SharePoint specific management tools are named with a verb-hypen-noun style. With these 531 cmdlets, there are 197 unique nouns, or different aspects of SharePoint that can be managed, and 38 unique verbs, or ways in which these parts of SharePoint may be administered. Certainly, it is not necessary to learn or memorize all of these cmdlets, but recommended that you focus on the areas of SharePoint you need to manage. Cmdlets such as Publish-SPServiceApplication and Ping-SPEnterpriseSearchContentService are some of the more esoteric.
If you start with just four verbs—get, set, new, and remove—you have 405 of the 531 cmdlets covered, and can focus on which aspects of SharePoint (nouns) you need to manage. Obviously, the remaining 126 cmdlets are used for something, but if they’re not applicable to your daily management needs, you could likely save learning about them until later.
As an example of learning related cmdlets, SharePoint’s dependence on SQL databases services as a good starting point. The generic noun to refer to these is SPDatabase, as used in the Get-SPDatabase cmdlet, while the other nouns are specific to a particular kind of SharePoint database, namely: SPConfigurationDatabase, SPContentDatabase, SPEnterpriseSearchCrawlDatabase, SPEnterpriseSearchPropertyDatabase, SPSingleSignOnDatabase, and SPStateServiceDatabase. Not all verbs work with all of these different types of databases (nouns). Although the most common verbs are Get, Set, New, and Remove, there is no Get nor Set cmdlet for either SPConfigurationDatabase or SPSingleSignOnDatabase.
In fact, while SPConfigurationDatabase has New and Remove cmdlets, yet no Set and Get, it also has Connect, Disconnect, and Backup cmdlets. Each kind if SharePoint database, like many other managed objects, has particular operations which make logical sense to meet their unique characteristics and management needs. The specific characteristics of the SPConfigurationDatabase and its cmdlets relate to the association of a SharePoint configuration database with a farm. The Connect-SPConfigurationDatabase cmdlet associates the current server with the specified configuration database, and therefore the farm. To move a server from one farm to another, first use the Disconnect-SPConfigurationDatabase to dissociate the server from its current farm, then use Connect-SPConfigurationDatbase cmdlet to associate the server with its new farm.
For example, to move the current server from the FINANCE farm to the MARKETING farm, use the following:
Disconnect-SPConfigurationDatabase
Connect-SPConfigurationDatabase -DatabaseServer clarityPRIMARYSERVER `
-DatabaseName SharePoint_Config
Another cmdlet associated with SPConfigurationDatabase is Backup-SPConfigurationDatabase, which backs up the specified configuration database, essentially backing up the farm configuration associated with that configuration database. A shared folder is specified as the backup destination. The content databases would be backed up independently, for example using the Backup-SPFarm cmdlet.
The configuration database for a farm is a tangible aspect of the management of a SharePoint deployment, yet its relationship to the SharePoint servers within a farm is not often reconfigured on a daily basis, yet when you add or remove servers to the farm. We’ve chosen this fairly static aspect of a SharePoint Server 2010 deployment as a starting point for further discussion. The SharePoint 2010 Management Shell can provide a wealth of opportunities for day-to-day administration automation, as perhaps we’ll address in future articles.