Wednesday, 8 June 2011

Powershell Setup for SharePoint Developers

Overview:  PowerGUI (from Quest Software) provides a PowerShell(PS) GUI to perform actions with minimal customisation you get Powershell with Intellesense and colour coding that is SharePoint aware.  Additionally you can plug in a Visual Studio (VS) plug-in (VSIX) that allows you to have PowerGUI functionality directly within you VS IDE.

1.> Install PowerGUI
1.1.> Download PowerGUI at I installed version 2.4.0
1.2.> Install the PowerGUI msi on your development server

2.> Configure PowerGUI
2.1.> Open the PowerGUI application
2.2.> Add the Microsoft.SharePoint.PowerShell module as shown below:
3.> Write a PS script
3.1.> Open the "PowerGUI Script Editor" by clicking Tools > PowerGUI Script Editor
3.2.> Ensure your intellesense is working by typing "Get-SP", you will see the intellisense pick up the GET-SPSite cmdlet.
3.3> Add the following command and debug with a break point to see PowerGUI in action.  This will get all the Content Types associated to the RootWeb of a specific Site Collection.  Note the variables windows on the right hand side of the PowerGUI interfaces allows you to examine each of the variable objects declared in the script.
It's not full intellesense but it is a huge help to get you most of the way to writing custom PS.

4.> Add PowerGUI Visual Studio 2010
4.1.> Add the "PowerGUI VSX" through extension manager (VSIX) (Tools > Extension Manager > Online Gallery > Search for .. PowerGUI > Download.
4.2.> VS2010 will reboot, ensure VS2010 is open, click "View" > "PowerGUI Console".  You can use the console to write PS.
4.3.>  The VSIX also provides an SPI for adding PS Scripts as shown below:

Error msg:
PS E:\Windows\system32> Add-PSSnapin -Name Microsoft.SharePoint.PowerShell
Add-PSSnapin : The Windows PowerShell snap-in 'Microsoft.SharePoint.PowerShell' is not installed on this machine.

PowerGUI and SharePoint 2010

Update: 19/07/2012 - I downloaded the latest version of PowerGui and tried to call SharePoint scripts arfer adding the SP add-in and got the following error:
Get-SPFarm : Microsoft SharePoint is not supported with version 4.0.30319.237 of the Microsoft .Net RuntimeFix navigate to: C:\Program Files (x86)\PowerGUI\ScriptEditor.exe.config and edit the xml.  I comented out the line telling PowerGui to use .NET 4.0.


Post a Comment