How to debug powershell scripts


In this article you will learn how to debug powershell scripts using Windows powershell ISE.

For a developer or an administrator debugging the scripts is one of the common tasks. So the tool that helps to debug is..

Windows PowerShell ISE:

Windows Powershell ISE tool  come along with the installation of windows server 2012.

Once you click on the Windows Powershell ISE  App, It will open the below screen. Where you can create a new script file by choosing file icon.

I am using the once of scripts which you have seen in this blog for the demo.

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.


Conclusion:

In this article you have seen how to debug the powershell scripts using Windows powershell ISE.


› How to debug Powershell scripts.

About Author

Devendra Velegandla is a four-time recipient of Microsoft's Most Valuable Professional (MVP) award (2014-2017) for Office Servers and Services MVP and  SharePoint Server.He received the MCC award for his contributions in Microsoft MSDN/TechNet forums.He loves sharing articles, videos and tutorial on SharePoint and Office 365.


If you found this post helpful, please share with your friends!!


Join 5,500 subscribers and receive instant access to

Devendra's Library of Resources for SharePoint Developers