One of the cool new features introduced in SharePoint 2010 are the new set of PowerShell Cmdlets for SharePoint. I have been working on those PowerShell Cmdlets for some time now (mainly configuring SharePoint service applications than development) and I am quite impressed to see how simple things are!
If you are using MOSS 2007, stsadm command is the tool you would use to configure and manage your SharePoint environment. The SharePoint community was the only resource if you were looking to leverage the PowerShell strength in MOSS 2007. From SharePoint 2010, though the stsadm command is still available, Microsoft recommends using the new PowerShell Cmdlets which are more efficient than using stsadm command. In fact, there is a PowerShell Cmdlet for everything and anything in SharePoint 2010!
Where to Begin?
There are two ways to start using the PowerShell Cmdlets:
1) From the SP2010 Management Shell
This opens a PowerShell Console session with all the cmdlets loaded.
2) Adding the Microsoft.SharePoint.PowerShell snap-in
You can also open a new PowerShell window, add the Microsoft.SharePoint.PowerShell snap-in to start using the cmdlets.
Now the real fun begins
There are more than 500 cmdlets in total! Well, I have to really appreciate Dmitry for putting up the available cmdlets in his blog! So, I wont repeat them here. Remember, that list is not final, but still it gives you an idea of what is possible now.
Some examples for Administrators
Though I see a major investment for developers too, the Administrators are the ones who are going to benefit a lot from these cmdlets.
Some examples are below. Please bear in mind that this is still in beta and things may change gradually as it reaches the final release:
[These cmdlets involves the use of new Service Applications introduced in SharePoint 2010]
Creating a new User Profile Service Application and User Profile Service Application Proxy
-Name "Demo User Profile Service"
-ApplicationPool "SharePoint Web Services Default"
-SocialDBName "DEMO2010A_SocialDB" -Verbose
-Name "Demo User Profile Service Proxy"
Note that this is also attaching existing databases for Profile, Social and Sync databases. This is useful when you are restoring the Users’ Profile, MySites databases and want to create a user profile service application based on those restored databases. If you dont supply any values for database, it should create a new databases.
Creating a new Secure Store Master Key & Application Key
The Secure Store Service Application manages the secure store accounts which we can use in many other service applications like Visio Services, Performance Point Services etc., for setting up authentication with external data sources. This initially requires a Master Key and Application Key to be generated based on which you can now create target applications IDs and set credentials and permissions. So below is the PowerShell script to create these initial keys:
First, let us get a reference to the secure store service application:
Setting the unattended account for Performance Point Services
Below is the PowerShell script to set the unattended account for authenticating with external data sources. Note how it also uses PSCredential object to get the user credentials:
(New-Object System.Management.Automation.PSCredential "username",
(ConvertTo-SecureString "password" -AsPlainText -Force))
But for now I will leave you to explore the possibilities of the other PowerShell cmdlets like:
And some link love to Zach’s excellent blog posts:
I will post more cmdlets as I start using them here in my blogby