PowerShell Code Generator

Brings rich PowerShell functionalities into VS Templating. You can access the file system, the registry, and many other PowerShell features to templating. You can also run PowerShell cmdlets, import modules and more.

Features

How to install PowerShell Code Generator

  1. Download the zip
  2. Unzip
  3. Run .\Install-PSCodeGenerator.ps1 at the PowerShell console prompt
  4. Copies the templates for use in Visual Studio
  5. Registers the the PowerShell code generator custom tool

How to use PSCodeGenerator

These are the manual steps needed to enable the PowerShell Code Generator custom tool. Or you can use the templates that get installed. Properties Window
Solution Explorer

1..2 | % {
"
public class Test$($_) {
}

"
}

VS 2010 PowerShell Templates

Here a the templates currently included.
PowerShell Templates

Examples

PowerShell

$extension="generated.cs"

"
// <auto-generated>
// Generated at $(Get-Date)
// </auto-generated>
"

Generates

Dynamic code generation

Static SQL Example

$extension="sql"

"
create procedure Products_Delete
    @ProductID int
as
    delete from Products
    where ProductID = @ProductID
"

Generates

SQL Generation