The past few weeks, I have been writting a lot of PowerShell scripts so I can automate as many SharePoint administrative tasks that I can so I can enjoy other aspects of SharePoint during the business day.
I found a must have statement from the book, “PowerShell for Microsoft SharePoint 2010 Administrators“, book.
Here is the statement. This statement is important if you have a scheduled task or a program that kicks off programs.
I have a template now to make sure I have this statement right underneath my opening comments area.
[box type="info"]Example: If (-not(Get-PSSnapin | Where-Object { $_.Name -eq “Microsoft.SharePoint.PowerShell”})) {Add-PSSnapin Microsoft.SharePoint.PowerShell;}[/box]