Sunday, May 4, 2014

How to debug PowerShell custom Cmdlet project

In order to debug PowerShell go to the following path

Solution explorer à Right Click properties à debug

Here we need to configure the following three values

Start external program : mention the location of the powershell directory here usually it is “C:\WINDOWS\system32\WindowsPowerShell\v1.0\powershell.exe”

Next define Command line argument : -noexit -command Add-PSSnapin XXXX.PowerShell (replace  XXXX.PowerShell with the value you have defined in the “Name” property of the installer file )


Finally define the Working Directory : This is location where your project is building and placing the dlls, 

Note : In some cases you may require to copy dll from this location to the the GAC of the server, therefore every time you make a change in your code you may be required to update the dlls in the GAC. You may also need to sign your assembly with a strong name in case the same has to be copied to GAC.


No comments: