Tuesday, January 7, 2014

How to debug Powershell Scripts for SharePoint 2010/2013

Using Windows powershell ISE, you can debug the powershell scripts. Windows Powershell ISE tool  come along with the installation of windows server 2012.

To debug the script select the line of code where you want to place the breakpoint and then go to "Debug" menu option and click on "Toggle BreakPoint" or F9. This will add the breakpoint. -
 When you execute the script by pressing F5 keyword, once it hits the breakpoint you can debug the scripts. See the below screenshot where we are finding the value of "$webapp" which webapplication value.

More info:

Use PowerGUI script editor for executing sharepont2010 powershell. There are two main advantages of using PowerGUI:
1. Dubugging of powershell script
2. Intellisense support

So, let's start setting up PowerGUI to use with sharepoint 2010:
Download and install latest version of PowerGUI.
Download PowerGUI PowerPack for sharepoint.

*Start PowerGUI script editor​ and go to File > Powershell Libraries
*Click on "Add Module" and add downloaded "PowerPack for sharepoint" library here
*That will add another entry "Microsoft.Sharepoint.PowerShell" into the listing. Check the library to make it enable.

*Restart PowerGUI script editor and you are ready to get started.

1 comment:

  1. Whare is "PowerGUI PowerPack for SharePoint." now? Quest does not have it