If you’ve had the opportunity to work with any of the new Microsoft server products, you’ve undoubtedly become aware of the power of the PowerShell commandlets that ship with many of the new products. As a developer at heart, and a SharePoint developer/administrator by trade; I am enlightened daily by the many things that are possible with the SharePoint 2010 Management Shell. In a world where we are constantly seeking more and more automation, developers and admins alike are going to have to get comfortable writing code… I mean scripts.
I was faced with an example of this today. I was assisting in the building of a new SharePoint 2010 farm and I had noticed that the Usage and Health Data Service Application Proxy was stopped. Having seen this before, I knew that there wasn’t a way (at least that I know of) to start the service application proxy from Central Administration, so I would have to resort to the SharePoint 2010 Management Shell; which I am growing to love more and more by the day. A quick two lines of script, and the service application proxy was back online:
$svcAppProxy = Get-SPServiceApplicationProxy | Where {$_.Name -eq "Usage and Health Data Service Application Proxy"}
$svcAppProxy.Provision()
#End
Almost seems too easy, doesn’t it?
Now, I know this this is a pretty basic example but I feel it is worth noting for these two very important reasons:
The thing that I always hated about batch files and STSADM was the fact that writing batch commands was such a cryptic experience. We’re used to nice IDEs, so if we are going to be expected to write scripts for these products; we’ll need good tools to write and test our scripts.
The community around PowerShell is growing and so are the tools. Personally, I’m a fan of PowerGUI by Quest Software. PowerGUI can load external PowerShell libraries (like SharePoint) and even has intellisense, as shown in the screen captures below:
As you can see, with the right set of tools; our script from above is pretty simple isn’t it?