PowerShell Code Generator

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

This example creates a function New-Class that generates a class and properties. This function can easily be placed in the PowerShell Code Generator profile which is stored in $PSCGProfile. PowerShell code stored there is accessible at all times for templating needs.

PowerShell Code Generation

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

Last edited Jun 18, 2010 at 1:47 AM by dfinke, version 16