How to debug Powershell commandlets?
am 04.11.2007 10:58:41 von Alexander VasilevskyHi!
How to debug Powershell commandlets?
--
http://www.alvas.net - Audio tools for C# and VB.Net developers
Hi!
How to debug Powershell commandlets?
--
http://www.alvas.net - Audio tools for C# and VB.Net developers
"Alexander Vasilevsky"
news:fgk54e$l1v$1@behemoth.volia.net...
> Hi!
>
> How to debug Powershell commandlets?
>
First, you have to register the debug version of your snap-in. You must be
an administrator to do that but, you only have to do that once (and when
your version changes). I always register my snap-ins twice, once with
"Debug." prepended to the name and once without. Obviously, the "debug"
points to the dll in my development debug directory.
Once you have that set, go into the project's "Properties", pick the "Debug"
tab and change the Start Action to "Start External Program" and locate
PowerShell.exe as the external program. Then, in the "Start Options",
"Command line arguments", enter:
-NoExit -Command Add-PSSnapin Debug.YourSnapin
(Assuming that your snapin is registered as "Debug.Yoursnapin")
After that, you just hit F5 and you get a powershell prompt with your snapin
enabled, enter whatever command you want to debug. You can set breakpoints
etc, etc.