CmdID / PowerShell / Cmdlets / New
New-IseSnippet
Creates a Windows PowerShell ISE code snippet. PowerShell reference
From the PowerShell reference 6 parameters
What it does
Creates a Windows PowerShell ISE code snippet. 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 <kbd>CTRL</kbd>+<kbd>J</kbd>. 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. You cannot use user-created snippets in a session in which the execution policy is Restricted or AllSigned. This cmdlet was introduced in Windows PowerShell 3.0.
New-IseSnippet [-Title] <String> [-Description] <String> [-Text] <String> [-Author <String>] [-CaretOffset <Int32>] [-Force] [<CommonParameters>]
Create a Comment-Based help snippet
New-IseSnippet -Title Comment-BasedHelp -Description "A template for comment-based help." -Text "<#
.SYNOPSIS
.DESCRIPTION
.PARAMETER <Parameter-Name>
.INPUTS
.OUTPUTS
.EXAMPLE
.LINK
#>"IdentifyCreate a mandatory snippet
$M = @'
param
(
[Parameter(Mandatory=$true)]
[string[]]
$<ParameterName>
)
'@
$snippet = @{
Text = $M
Title = 'Mandatory'
Description = 'Adds a mandatory function parameter.'
Author = 'Patti Fuller, Fabrikam Corp.'
Force = $true
}
New-ISESnippet @snippetIdentifyCopy a mandatory snippet from a folder to a destination folder
$path = "$HOME\Documents\WindowsPowerShell\Snippets\Mandatory.Snippets.ps1xml"
$destination = "\\Server\Share"
Copy-Item -Path $path -Destination $destinationIdentifyTrips 1 Sigma rule: mediumCopy From Or To Admin Share Or Sysvol Folder by Florian Roth (Nextron Systems), oscd.community, Teymur Kheirkhabarov @HeirhabarovT, Zach Stanford @svch0st, Nasreddine Bencherchali
Its page in the reference: New-IseSnippet.
Parameters
-AuthorSpecifies the author of the snippet. The author field appears in the snippet file, but it does not appear when you click the snippet name in Windows PowerShell ISE.-CaretOffsetSpecifies the character of the snippet text that this cmdlet places the cursor on. Enter an integer that represents the cursor position, with "1" representing the first character of text. The default value, 0 (zero), places the cursor immediately before the first character of text. This parameter does not indent the snippet text.-DescriptionSpecifies a description of the snippet. The description value appears when you click the snippet name in Windows PowerShell ISE. This parameter is required.-ForceIndicates that this cmdlet overwrites snippet files with the same name in the same location. By default, New-ISESnippet does not overwrite files.-TextSpecifies the text value that is added when you select the snippet. The snippet text appears when you click the snippet name in Windows PowerShell ISE. This parameter is required.-TitleSpecifies a title or name for the snippet. The title also names the snippet file. This parameter is required.