VS Code Powershell Snippets

Hey Folks,

currently reading through “Powershell scripting in a month of lunches” and finally made my switch to VS Code. I’d consider myself an “advanced” user and noticed that the VS Code Powershell Snippets do not satisfying my needs. That’s why i’ve built my own and felt like sharing. You can add these two to your powershell.json if you like:

"Name (not shown)": { "prefix": "Name (IntelliSense)", "body": [ "Code1", "tCode2 Tabbed" ], "description": "Description" }, "TM Function": { "prefix": "Function [TM]", "body": [ "Function Verb-Noun", "{", "t[CmdletBinding(ConfirmImpact=String,", "tDefaultParameterSetName=String,", "tHelpURI=URI,", "tSupportsPaging=Boolean,", "tSupportsShouldProcess=Boolean,", "tPositionalBinding=Boolean)]", "t", "tParam(", "tt", "t)", "t", "tBegin {", "tt", "t}", "t", "tProcess {", "tt", "t}", "t", "tEnd {", "tt", "t}", "}" ], "description": "Basic Function Block" }, "TM Parameter": { "prefix": "Parameter [TM]", "body": [ "[Parameter(Mandatory=Boolean,", "Position=int,", "ParameterSetName=String", "ValueFromPipeline=Boolean,", "ValueFromPipelineByPropertyName=Boolean,", "ValueFromRemainingArguments=Boolean)]", "[Alias(string)]", "[ValidateNotNull()]", "[ValidateNotNullOrEmpty()]", "[ValidateSet(String1, String2)]", "[ValidateCount(int_min, int_max)]", "[ValidateLength(int_min, int_max)]", "[ValidateRange(int_min, int_max)]", "[ValidatePattern(RegexPattern)]", "[ValidateScript({Expression})]", "[AllowNull()]", "[AllowEmptyString()]", "[AllowEmptyCollection()]", "[Type[]]", "$$Name", ], "description": "Basic Parameter Block" } 

submitted by /u/philmph
[link] [comments]

Leave a Reply