Powershell CMDLET Development Settings

PowerShell snapins are a great way of exposing useful tools to your team, we can provide hooks into our existing code allowing us to leverage the investment in the code base through a simple cmdlet.</p align=”justify”>

There is a bit of a gotcha with PowerShell development however; if you need to be able to execute .NET 4 assemblies within PowerShell you will need to add a little extra configuration to each computer that will need to utilize your .NET 4 assemblies.</p align=”justify”>

  • Create a file in “C:\Windows\SysWOW64\WindowsPowerShell\v1.0\” named “powershell.exe.config”.
  • Open this file in a text editor; this will need to be running “as an Administrator”
  • Paste the following XML into the text editor

Once this is in place you are set to load any .NET v4.0 or v2.0 assembly into PowerShell.</p align=”justify”>

There are a large number of excellent articles on creating PowerShell snapins in .NET so I won’t re-invent the wheel.</p align=”justify”>

At some point you will want to test and debug your snapin; you can save yourself a lot of time and hassle by automating the uninstallation and re-instalation of the Snapin with the following pre-build and post build events:</p align=”justify”>



If you are not familiar with Visual Studio 2010 build events, you can access them by right clicking on your Project, then selecting properties; “Build Events” appears as a tab down the left hand side.</p align=”justify”>

If you want a full F5 experience when developing PowerShell cmdlets:</p align=”justify”>

  • Select the “Debug” tab from project properties
  • Select “Start External Program” as the start action
  • In the text box enter
  • Enter

as command line arguments.

  1. Thank you so much for your time in developing this educative article.

Leave a Reply

Your email address will not be published. Required fields are marked *