Create a New PowerShell ISE snippet

Hello,

Since PowerShell 3, we have an incredibly good Integrated Scripting Environment shipped with for free.I kind of fan of the “Ctrl+J” shortcut, or “Edit -> Start Snippets”. You have instant access to a lot of code structure of PowerShell scriptword, of functions templates, as well as DSC templates¬†:

PowerShell.ISE.Snippets.1

If this is not enough for you, you can create your own snippets code, just like that :

$snippet = @{
    Title = "Help";
    Description = "Standard script Help";
    Text = @"
    <#
    .SYNOPSIS
    .DESCRIPTION
    .EXAMPLE
    .PARAMETER
    .INPUTS
    .OUTPUTS
    .NOTES
    .LINK
        http://ItForDummies.net
    #>
"@
}
New-IseSnippet @snippet

You can write whatever you want in the herestring, you can even use variables. You may want to use the “-Force” on New-IseSnippet if you need to modify an existing one.

Once you’re done, “Ctrl+J” again :

PowerShell.ISE.Snippets.3

All your custom snippets are stored next to your PowerShell profile :

 C:Users$env:usernamedocumentsWindowsPowerShellsnippets

 

0 thoughts on “Create a New PowerShell ISE snippet

Leave a Reply