PowerShell Logo Small


This is the built-in help made by Microsoft for the command 'New-IseSnippet', in PowerShell version 5 - as retrieved from Windows version 'Microsoft Windows Server 2012 R2 Standard' PowerShell help files on 2016-06-23.

For PowerShell version 3 and up, where you have Update-Help, this command was run just before creating the web pages from the help files.


Creates a Windows PowerShell ISE code snippet.


New-IseSnippet [-Title] <String> [-Description] <String> [-Text] <String> [-Author <String>] [-CaretOffset <Int32>] [-Force] [<CommonParameters>]

Search powershellhelp.space


The New-ISESnippet cmdlet creates a reusable text "snippet" for Windows PowerShell ISE. You can use snippets to add text to the Script pane or Command pane in Windows
PowerShell ISE. This cmdlet is available only in Windows PowerShell ISE.

Beginning in Windows PowerShell 3.0, Windows PowerShell ISE includes a collection of built-in snippets. The New-ISESnippet cmdlet lets you create your own snippets to add to
the built-in collection. You can view, change, add, delete, and share snippet files and include them in Windows PowerShell modules. To see snippets in Windows PowerShell
ISE, from the Edit menu, select Start Snippets or press CTRL+J.

The New-ISESnippet cmdlet creates a <Title>.Snippets.ps1xml file in the $home\Documents\WindowsPowerShell\Snippets directory with the title that you specify. To include a
snippet file in a module that you are authoring, add the snippet file to a Snippets subdirectory of your module directory.

Note: You cannot use user-created snippets in a session in which the execution policy is AllSigned or Restricted. For more information, see the Notes section.

This cmdlet is introduced in Windows PowerShell 3.0.



Online Version: http://go.microsoft.com/fwlink/p/?linkid=287357




-------------------------- EXAMPLE 1 --------------------------

PS C:\>New-IseSnippet -Title Comment-BasedHelp -Description "A template for comment-based help." -Text "<#
.PARAMETER <Parameter-Name>

This command creates a Comment-BasedHelp snippet for Windows PowerShell ISE. It creates a file named "Comment-BasedHelp.snippets.ps1xml" in the user's Snippets directory

-------------------------- EXAMPLE 2 --------------------------

PS C:\>$m = @'

PS C:\>New-ISESnippet -Text $m -Title Mandatory -Description "Adds a mandatory function parameter." -Author "Kim Akers, Fabrikam Corp." -Force

These commands create a Mandatory snippet for Windows PowerShell ISE. The first command saves the snippet text in the $m variable. The second command uses the New-ISESnippet
cmdlet to create the snippet. The command uses the Force parameter to overwrite a previous snippet with the same name.

-------------------------- EXAMPLE 3 --------------------------

PS C:\>Copy-Item $home\Documents\WindowsPowerShell\Snippets\Mandatory.Snippets.ps1xml -Destination \\Server\Share

This command uses the Copy-Item cmdlet to copy the Mandatory snippet from the folder where New-ISESnippet places it to the Server\Share file share.

Because the Snippets.ps1xml files that New-ISESnippet creates are text (XML) files, you can use the Item cmdlets to get, changes, move, rename, and copy them.