<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Media And Microcode : Cmdlet</title><link>http://blogs.msdn.com/mediaandmicrocode/archive/tags/Cmdlet/default.aspx</link><description>Tags: Cmdlet</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Microcode: Debugging Cmdlets and Providers with Visual Studio and CTP2</title><link>http://blogs.msdn.com/mediaandmicrocode/archive/2008/07/27/microcode-debugging-cmdlets-and-providers-with-visual-studio-and-ctp2.aspx</link><pubDate>Sun, 27 Jul 2008 09:43:38 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8777584</guid><dc:creator>JamesBrundage</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/mediaandmicrocode/comments/8777584.aspx</comments><wfw:commentRss>http://blogs.msdn.com/mediaandmicrocode/commentrss.aspx?PostID=8777584</wfw:commentRss><description>&lt;p&gt;In PowerShell CTP2, you have a nice cmdlet, Add-Module, that frees you from the constraints of having to declare a snapin.&amp;#160; By using Add-Module, you can take any old library of code and load it to find cmdlets or providers.&amp;#160; This means that debugging your cmdlets and providers in Visual Studio is a real snap.&lt;/p&gt;  &lt;p&gt;To debug a cmdlet or provider using Windows Powershell CTP2, right click the project file containing your cmdlet, then click properties, then Debug.&amp;#160; Change it to Start External Program and put either C:\Windows\System32\WindowsPowerShell\v1.0\gpowershell.exe (Graphical PowerShell) or C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe (Console PowerShell)&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;a href="http://blogs.msdn.com/blogfiles/mediaandmicrocode/WindowsLiveWriter/MicrocodeDebuggingCmdletsandProviderswit_14DAD/DebuggingVisualStudio.jpg"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="482" alt="DebuggingVisualStudio" src="http://blogs.msdn.com/blogfiles/mediaandmicrocode/WindowsLiveWriter/MicrocodeDebuggingCmdletsandProviderswit_14DAD/DebuggingVisualStudio_thumb.jpg" width="644" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;You can also simply edit the .csproj.user file in the same directory.&amp;#160; This file stores user settings for debugging a Visual Studio project.&amp;#160; Here's mine:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&amp;lt;Project xmlns=&amp;quot;&lt;a href="http://schemas.microsoft.com/developer/msbuild/2003""&gt;http://schemas.microsoft.com/developer/msbuild/2003&amp;quot;&lt;/a&gt;&amp;gt;      &lt;br /&gt;&amp;#160; &amp;lt;PropertyGroup Condition=&amp;quot; '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' &amp;quot;&amp;gt;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;StartAction&amp;gt;Program&amp;lt;/StartAction&amp;gt;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;StartProgram&amp;gt;C:\Windows\System32\WindowsPowerShell\v1.0\gpowershell.exe&amp;lt;/StartProgram&amp;gt;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;StartArguments&amp;gt;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/StartArguments&amp;gt;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;StartWorkingDirectory&amp;gt;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/StartWorkingDirectory&amp;gt;      &lt;br /&gt;&amp;#160; &amp;lt;/PropertyGroup&amp;gt;      &lt;br /&gt;&amp;lt;/Project&amp;gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Once you debug, you'll be in the same directory as all of the compiled DLLs.&amp;#160; Simply run the following command (replace cmdlet.dll with your own cmdlet) and you'll be able to debug your cmldet or provider.&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;Add-Module&lt;em&gt; Cmdlet.Dll&lt;/em&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Add-Module is something that's only part of &lt;a href="http://www.microsoft.com/downloads/details.aspx?familyid=7C8051C2-9BFC-4C81-859D-0864979FA403&amp;amp;displaylang=en"&gt;Windows PowerShell CTP2&lt;/a&gt;, but the debugging tricks will also work with a cmdlet installed with InstallUtil.&lt;/p&gt;  &lt;p&gt;Hope this helps,&lt;/p&gt;  &lt;p&gt;James Brundage [MSFT]&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8777584" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/mediaandmicrocode/archive/tags/Microcode/default.aspx">Microcode</category><category domain="http://blogs.msdn.com/mediaandmicrocode/archive/tags/Cmdlet/default.aspx">Cmdlet</category><category domain="http://blogs.msdn.com/mediaandmicrocode/archive/tags/Provider/default.aspx">Provider</category><category domain="http://blogs.msdn.com/mediaandmicrocode/archive/tags/Debugging/default.aspx">Debugging</category></item></channel></rss>