Sample code to create "PSCredential" ISE code snippet
New-IseCustomSnippet -Title "PSCredential" -Description "Create new PSCredential object" -ScriptBlock {
$cred = New-Object Management.Automation.PsCredential("Administrator", (ConvertTo-SecureString "<#Stub#>" -AsPlainText -Force))
}Sample code to create "Stopwatch" ISE code snippet
New-IseCustomSnippet -Title "Stopwatch" -Description "Measure PowerShell code block execution times" -ScriptBlock {
$sw = [Diagnostics.Stopwatch]::StartNew()
foreach($i in 1..1000)
{
#Stub
}
$elapsed = $sw.Elapsed
Write-Host ("Elapsed {0} [ms]" -f $elapsed.TotalMilliseconds)
}Registered snippets are stored in "snippets" folder at user profile path.
#Get snippets folder path
Join-Path (Split-Path -Parent $profile) "snippets" -ResolvePress Ctrl+J on ISE editer to show registered snippets list. If you don't use ISE default snippets. set following ISE options
$psISE.Options.ShowDefaultSnippets =$false