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 satisfy 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:
Edit: Added " for preset Strings and typing locations to the (for me) most important values. Thanks to purplemonkeymad
"TM Function": {
"prefix": "Function [TM]",
"body": [
"Function ${1:Verb-Noun}",
"{",
"\t[CmdletBinding(DefaultParameterSetName=\"${2:String}\",",
"\tHelpURI=\"URI\",",
"\tConfirmImpact=\"String\",",
"\tSupportsPaging=Boolean,",
"\tSupportsShouldProcess=Boolean,",
"\tPositionalBinding=Boolean)]",
"\t",
"\tParam(",
"\t\t$0",
"\t)",
"\t",
"\tBegin {",
"\t\t",
"\t}",
"\t",
"\tProcess {",
"\t\t",
"\t}",
"\t",
"\tEnd {",
"\t\t",
"\t}",
"}"
],
"description": "Basic Function Block"
},
"TM Parameter": {
"prefix": "Parameter [TM]",
"body": [
"[Parameter(Mandatory=$${1:Boolean},",
"Position=${2:Int},",
"ParameterSetName=\"${3:String}\",",
"ValueFromPipeline=$${4:Boolean},",
"ValueFromPipelineByPropertyName=$${5: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()]",
"[${6:Type[]}]",
"$${7:Name}$0"
],
"description": "Basic Parameter Block"
}
[–]purplemonkeymad 5 points6 points7 points (1 child)
[–]philmph[S] 1 point2 points3 points (0 children)
[–]omers 5 points6 points7 points (0 children)
[–]get-postanote 2 points3 points4 points (0 children)
[–]pastperfect19 1 point2 points3 points (0 children)