mirror of
https://github.com/kforney/pentest-distro-builder.git
synced 2024-11-29 03:31:59 -07:00
956 lines
34 KiB
JSON
956 lines
34 KiB
JSON
{
|
|
"ModuleManifest": {
|
|
"prefix": "manifest",
|
|
"body": [
|
|
"@{",
|
|
"\t# If authoring a script module, the RootModule is the name of your .psm1 file",
|
|
"\tRootModule = '${module:MyModule}.psm1'",
|
|
"",
|
|
"\tAuthor = '${author:Cool Person <coolperson@email.local>}'",
|
|
"",
|
|
"\tCompanyName = '${company:Contoso Inc.}'",
|
|
"",
|
|
"\tModuleVersion = '${ModuleVersion:0.1}'",
|
|
"",
|
|
"\t# Use the New-Guid command to generate a GUID, and copy/paste into the next line",
|
|
"\tGUID = '<pasteNewGUIDhere>'",
|
|
"",
|
|
"\tCopyright = '2017 ${company:Copyright Holder}'",
|
|
"",
|
|
"\tDescription = '${Description:What does this module do?}'",
|
|
"",
|
|
"\t# Minimum PowerShell version supported by this module (optional, recommended)",
|
|
"\t# PowerShellVersion = ''",
|
|
"",
|
|
"\t# Which PowerShell Editions does this module work with? (Core, Desktop)",
|
|
"\tCompatiblePSEditions = @('Desktop', 'Core')",
|
|
"",
|
|
"\t# Which PowerShell functions are exported from your module? (eg. Get-CoolObject)",
|
|
"\tFunctionsToExport = @('')",
|
|
"",
|
|
"\t# Which PowerShell aliases are exported from your module? (eg. gco)",
|
|
"\tAliasesToExport = @('')",
|
|
"",
|
|
"\t# Which PowerShell variables are exported from your module? (eg. Fruits, Vegetables)",
|
|
"\tVariablesToExport = @('')",
|
|
"",
|
|
"\t# PowerShell Gallery: Define your module's metadata",
|
|
"\tPrivateData = @{",
|
|
"\t\tPSData = @{",
|
|
"\t\t\t# What keywords represent your PowerShell module? (eg. cloud, tools, framework, vendor)",
|
|
"\t\t\tTags = @('${tag1:cooltag1}', '${tag2:cooltag2}')",
|
|
"",
|
|
"\t\t\t# What software license is your code being released under? (see https://opensource.org/licenses)",
|
|
"\t\t\tLicenseUri = ''",
|
|
"",
|
|
"\t\t\t# What is the URL to your project's website?",
|
|
"\t\t\tProjectUri = ''",
|
|
"",
|
|
"\t\t\t# What is the URI to a custom icon file for your project? (optional)",
|
|
"\t\t\tIconUri = ''",
|
|
"",
|
|
"\t\t\t# What new features, bug fixes, or deprecated features, are part of this release?",
|
|
"\t\t\tReleaseNotes = @'",
|
|
"'@",
|
|
"\t\t}",
|
|
"\t}",
|
|
"",
|
|
"\t# If your module supports updateable help, what is the URI to the help archive? (optional)",
|
|
"\t# HelpInfoURI = ''",
|
|
"}"
|
|
],
|
|
"description": "Basic skeleton for a PowerShell module manifest, complete with PowerShell Gallery metadata."
|
|
},
|
|
"Example-Class": {
|
|
"prefix": "ex-class",
|
|
"body": [
|
|
"class ${1:MyClass} {",
|
|
"\t# Property: Holds name",
|
|
"\t[String] \\$Name",
|
|
"",
|
|
"\t# Constructor: Creates a new MyClass object, with the specified name",
|
|
"\t${1:MyClass}([String] \\$NewName) {",
|
|
"\t\t# Set name for ${1:MyClass}",
|
|
"\t\t\\$this.Name = \\$NewName",
|
|
"\t}",
|
|
"",
|
|
"\t# Method: Method that changes \\$Name to the default name",
|
|
"\t[void] ChangeNameToDefault() {",
|
|
"\t\t\\$this.Name = \"DefaultName\"",
|
|
"\t}",
|
|
"}"
|
|
],
|
|
"description": "Example: class snippet with a constructor, property and a method"
|
|
},
|
|
"Example-Cmdlet": {
|
|
"prefix": "ex-cmdlet",
|
|
"body": [
|
|
"<#",
|
|
".SYNOPSIS",
|
|
"\tShort description",
|
|
".DESCRIPTION",
|
|
"\tLong description",
|
|
".EXAMPLE",
|
|
"\tExample of how to use this cmdlet",
|
|
".EXAMPLE",
|
|
"\tAnother example of how to use this cmdlet",
|
|
".INPUTS",
|
|
"\tInputs to this cmdlet (if any)",
|
|
".OUTPUTS",
|
|
"\tOutput from this cmdlet (if any)",
|
|
".NOTES",
|
|
"\tGeneral notes",
|
|
".COMPONENT",
|
|
"\tThe component this cmdlet belongs to",
|
|
".ROLE",
|
|
"\tThe role this cmdlet belongs to",
|
|
".FUNCTIONALITY",
|
|
"\tThe functionality that best describes this cmdlet",
|
|
"#>",
|
|
"function ${name:Verb-Noun} {",
|
|
"\t[CmdletBinding(DefaultParameterSetName='Parameter Set 1',",
|
|
"\t SupportsShouldProcess=\\$true,",
|
|
"\t PositionalBinding=\\$false,",
|
|
"\t HelpUri = 'http://www.microsoft.com/',",
|
|
"\t ConfirmImpact='Medium')]",
|
|
"\t[Alias()]",
|
|
"\t[OutputType([String])]",
|
|
"\tParam (",
|
|
"\t\t# Param1 help description",
|
|
"\t\t[Parameter(Mandatory=\\$true,",
|
|
"\t\t Position=0,",
|
|
"\t\t ValueFromPipeline=\\$true,",
|
|
"\t\t ValueFromPipelineByPropertyName=\\$true,",
|
|
"\t\t ValueFromRemainingArguments=\\$false, ",
|
|
"\t\t ParameterSetName='Parameter Set 1')]",
|
|
"\t\t[ValidateNotNull()]",
|
|
"\t\t[ValidateNotNullOrEmpty()]",
|
|
"\t\t[ValidateCount(0,5)]",
|
|
"\t\t[ValidateSet(\"sun\", \"moon\", \"earth\")]",
|
|
"\t\t[Alias(\"p1\")] ",
|
|
"\t\t\\$Param1,",
|
|
"\t\t",
|
|
"\t\t# Param2 help description",
|
|
"\t\t[Parameter(ParameterSetName='Parameter Set 1')]",
|
|
"\t\t[AllowNull()]",
|
|
"\t\t[AllowEmptyCollection()]",
|
|
"\t\t[AllowEmptyString()]",
|
|
"\t\t[ValidateScript({\\$true})]",
|
|
"\t\t[ValidateRange(0,5)]",
|
|
"\t\t[int]",
|
|
"\t\t\\$Param2,",
|
|
"\t\t",
|
|
"\t\t# Param3 help description",
|
|
"\t\t[Parameter(ParameterSetName='Another Parameter Set')]",
|
|
"\t\t[ValidatePattern(\"[a-z]*\")]",
|
|
"\t\t[ValidateLength(0,15)]",
|
|
"\t\t[String]",
|
|
"\t\t\\$Param3",
|
|
"\t)",
|
|
"\t",
|
|
"\tbegin {",
|
|
"\t}",
|
|
"\t",
|
|
"\tprocess {",
|
|
"\t\tif (\\$pscmdlet.ShouldProcess(\"Target\", \"Operation\")) {",
|
|
"\t\t\t$0",
|
|
"\t\t}",
|
|
"\t}",
|
|
"\t",
|
|
"\tend {",
|
|
"\t}",
|
|
"}"
|
|
],
|
|
"description": "Example: script cmdlet snippet with all attributes and inline help fields"
|
|
},
|
|
"Example-DSC Configuration": {
|
|
"prefix": "ex-DSC config",
|
|
"body": [
|
|
"configuration Name {",
|
|
"\t# One can evaluate expressions to get the node list",
|
|
"\t# E.g: \\$AllNodes.Where(\"Role -eq Web\").NodeName",
|
|
"\tnode (\"Node1\",\"Node2\",\"Node3\")",
|
|
"\t{",
|
|
"\t\t# Call Resource Provider",
|
|
"\t\t# E.g: WindowsFeature, File",
|
|
"\t\tWindowsFeature FriendlyName",
|
|
"\t\t{",
|
|
"\t\t\tEnsure = \"Present\"",
|
|
"\t\t\tName = \"Feature Name\"",
|
|
"\t\t}",
|
|
"",
|
|
"\t\tFile FriendlyName",
|
|
"\t\t{",
|
|
"\t\t\tEnsure = \"Present\"",
|
|
"\t\t\tSourcePath = \\$SourcePath",
|
|
"\t\t\tDestinationPath = \\$DestinationPath",
|
|
"\t\t\tType = \"Directory\"",
|
|
"\t\t\tDependsOn = \"[WindowsFeature]FriendlyName\"",
|
|
"\t\t}",
|
|
"\t}",
|
|
"}"
|
|
],
|
|
"description": "Example: DSC configuration snippet that uses built-in resource providers"
|
|
},
|
|
"Example-DSC Resource Provider (class-based)": {
|
|
"prefix": "ex-DSC resource provider (class-based)",
|
|
"body": [
|
|
"# Defines the values for the resource's Ensure property.",
|
|
"enum Ensure {",
|
|
"\t# The resource must be absent.",
|
|
"\tAbsent",
|
|
"\t# The resource must be present.",
|
|
"\tPresent",
|
|
"}",
|
|
"",
|
|
"# [DscResource()] indicates the class is a DSC resource.",
|
|
"[DscResource()]",
|
|
"class NameOfResource {",
|
|
"\t# A DSC resource must define at least one key property.",
|
|
"\t[DscProperty(Key)]",
|
|
"\t[string] \\$P1",
|
|
"\t",
|
|
"\t# Mandatory indicates the property is required and DSC will guarantee it is set.",
|
|
"\t[DscProperty(Mandatory)]",
|
|
"\t[Ensure] \\$P2",
|
|
"\t",
|
|
"\t# NotConfigurable properties return additional information about the state of the resource.",
|
|
"\t# For example, a Get() method might return the date a resource was last modified.",
|
|
"\t# NOTE: These properties are only used by the Get() method and cannot be set in configuration.",
|
|
"\t[DscProperty(NotConfigurable)]",
|
|
"\t[Nullable[datetime]] \\$P3",
|
|
"\t",
|
|
"\t[DscProperty()]",
|
|
"\t[ValidateSet(\"val1\", \"val2\")]",
|
|
"\t[string] \\$P4",
|
|
"\t",
|
|
"\t# Gets the resource's current state.",
|
|
"\t[NameOfResource] Get() {",
|
|
"\t\t# NotConfigurable properties are set in the Get method.",
|
|
"\t\t\\$this.P3 = something",
|
|
"\t\t# Return this instance or construct a new instance.",
|
|
"\t\treturn \\$this",
|
|
"\t}",
|
|
"\t",
|
|
"\t# Sets the desired state of the resource.",
|
|
"\t[void] Set() {",
|
|
"\t}",
|
|
"\t",
|
|
"\t# Tests if the resource is in the desired state.",
|
|
"\t[bool] Test() {",
|
|
"\t\t return \\$true",
|
|
"\t}",
|
|
"}"
|
|
],
|
|
"description": "Example: class-based DSC resource provider snippet"
|
|
},
|
|
"Example-DSC Resource Provider (function based)": {
|
|
"prefix": "ex-DSC resource provider (function based)",
|
|
"body": [
|
|
"function Get-TargetResource {",
|
|
"\t# TODO: Add parameters here",
|
|
"\t# Make sure to use the same parameters for",
|
|
"\t# Get-TargetResource, Set-TargetResource, and Test-TargetResource",
|
|
"\tparam (",
|
|
"\t)",
|
|
"}",
|
|
"function Set-TargetResource {",
|
|
"\t# TODO: Add parameters here",
|
|
"\t# Make sure to use the same parameters for",
|
|
"\t# Get-TargetResource, Set-TargetResource, and Test-TargetResource",
|
|
"\tparam (",
|
|
"\t)",
|
|
"}",
|
|
"function Test-TargetResource {",
|
|
"\t# TODO: Add parameters here",
|
|
"\t# Make sure to use the same parameters for",
|
|
"\t# Get-TargetResource, Set-TargetResource, and Test-TargetResource",
|
|
"\tparam (",
|
|
"\t)",
|
|
"}"
|
|
],
|
|
"description": "Example: function-based DSC resource provider snippet"
|
|
},
|
|
"Example-Path Processing for Non-Existing Paths": {
|
|
"prefix": "ex-path processing for non-existing paths",
|
|
"body": [
|
|
"# Modify [CmdletBinding()] to [CmdletBinding(SupportsShouldProcess=\\$true)]",
|
|
"\\$paths = @()",
|
|
"foreach (\\$aPath in \\$Path) {",
|
|
"\t# Resolve any relative paths",
|
|
"\t\\$paths += \\$psCmdlet.SessionState.Path.GetUnresolvedProviderPathFromPSPath(\\$aPath)",
|
|
"}",
|
|
"",
|
|
"foreach (\\$aPath in \\$paths) {",
|
|
"\tif (\\$pscmdlet.ShouldProcess(\\$aPath, 'Operation')) {",
|
|
"\t\t# Process each path",
|
|
"\t\t$0",
|
|
"\t}",
|
|
"}"
|
|
],
|
|
"description": "Example: processing non-existing paths typically used in New-* commands (for use in process block). See parameter-path snippet."
|
|
},
|
|
"Example-Path Processing for No Wildcards Allowed": {
|
|
"prefix": "ex-path processing for no wildcards allowed",
|
|
"body": [
|
|
"# Modify [CmdletBinding()] to [CmdletBinding(SupportsShouldProcess=\\$true)]",
|
|
"\\$paths = @()",
|
|
"foreach (\\$aPath in \\$Path) {",
|
|
"\tif (!(Test-Path -LiteralPath \\$aPath)) {",
|
|
"\t\t\\$ex = New-Object System.Management.Automation.ItemNotFoundException \"Cannot find path '\\$aPath' because it does not exist.\"",
|
|
"\t\t\\$category = [System.Management.Automation.ErrorCategory]::ObjectNotFound",
|
|
"\t\t\\$errRecord = New-Object System.Management.Automation.ErrorRecord \\$ex,'PathNotFound',\\$category,\\$aPath",
|
|
"\t\t\\$psCmdlet.WriteError(\\$errRecord)",
|
|
"\t\tcontinue",
|
|
"\t}",
|
|
"",
|
|
"\t# Resolve any relative paths",
|
|
"\t\\$paths += \\$psCmdlet.SessionState.Path.GetUnresolvedProviderPathFromPSPath(\\$aPath)",
|
|
"}",
|
|
"",
|
|
"foreach (\\$aPath in \\$paths) {",
|
|
"\tif (\\$pscmdlet.ShouldProcess(\\$aPath, 'Operation')) {",
|
|
"\t\t# Process each path",
|
|
"\t\t$0",
|
|
"\t}",
|
|
"}"
|
|
],
|
|
"description": "Example: processing non-wildcard paths that must exist (for use in process block). See parameter-path snippets."
|
|
},
|
|
"Example-Path Processing for Wildcards Allowed": {
|
|
"prefix": "ex-path processing for wildcards allowed",
|
|
"body": [
|
|
"# Modify [CmdletBinding()] to [CmdletBinding(SupportsShouldProcess=\\$true, DefaultParameterSetName='Path')]",
|
|
"\\$paths = @()",
|
|
"if (\\$psCmdlet.ParameterSetName -eq 'Path') {",
|
|
"\tforeach (\\$aPath in \\$Path) {",
|
|
"\t\tif (!(Test-Path -Path \\$aPath)) {",
|
|
"\t\t\t\\$ex = New-Object System.Management.Automation.ItemNotFoundException \"Cannot find path '\\$aPath' because it does not exist.\"",
|
|
"\t\t\t\\$category = [System.Management.Automation.ErrorCategory]::ObjectNotFound",
|
|
"\t\t\t\\$errRecord = New-Object System.Management.Automation.ErrorRecord \\$ex,'PathNotFound',\\$category,\\$aPath",
|
|
"\t\t\t\\$psCmdlet.WriteError(\\$errRecord)",
|
|
"\t\t\tcontinue",
|
|
"\t\t}",
|
|
"\t",
|
|
"\t\t# Resolve any wildcards that might be in the path",
|
|
"\t\t\\$provider = \\$null",
|
|
"\t\t\\$paths += \\$psCmdlet.SessionState.Path.GetResolvedProviderPathFromPSPath(\\$aPath, [ref]\\$provider)",
|
|
"\t}",
|
|
"}",
|
|
"else {",
|
|
"\tforeach (\\$aPath in \\$LiteralPath) {",
|
|
"\t\tif (!(Test-Path -LiteralPath \\$aPath)) {",
|
|
"\t\t\t\\$ex = New-Object System.Management.Automation.ItemNotFoundException \"Cannot find path '\\$aPath' because it does not exist.\"",
|
|
"\t\t\t\\$category = [System.Management.Automation.ErrorCategory]::ObjectNotFound",
|
|
"\t\t\t\\$errRecord = New-Object System.Management.Automation.ErrorRecord \\$ex,'PathNotFound',\\$category,\\$aPath",
|
|
"\t\t\t\\$psCmdlet.WriteError(\\$errRecord)",
|
|
"\t\t\tcontinue",
|
|
"\t\t}",
|
|
"\t",
|
|
"\t\t# Resolve any relative paths",
|
|
"\t\t\\$paths += \\$psCmdlet.SessionState.Path.GetUnresolvedProviderPathFromPSPath(\\$aPath)",
|
|
"\t}",
|
|
"}",
|
|
"",
|
|
"foreach (\\$aPath in \\$paths) {",
|
|
"\tif (\\$pscmdlet.ShouldProcess(\\$aPath, 'Operation')) {",
|
|
"\t\t# Process each path",
|
|
"\t\t$0",
|
|
"\t}",
|
|
"}"
|
|
],
|
|
"description": "Example: processing wildcard paths that must exist (for use in process block). See parameter-path-wildcards and parameter-literalpath snippets."
|
|
},
|
|
"Example-Splatting": {
|
|
"prefix": "ex-splat",
|
|
"body": [
|
|
"\\$Params = @{",
|
|
"\tModule = '*'",
|
|
"\tVerb = 'Get'",
|
|
"}",
|
|
"Get-Command @Params"
|
|
],
|
|
"description": "Example: PowerShell splatting technique snippet"
|
|
},
|
|
"Example-Switch": {
|
|
"prefix": "ex-switch",
|
|
"body": [
|
|
"switch (${variable:\\$x})",
|
|
"{",
|
|
"\t'${val:value1}' { $1 }",
|
|
"\t{\\$_ -in 'A','B','C'} {}",
|
|
"\t'value3' {}",
|
|
"\tDefault {}",
|
|
"}"
|
|
],
|
|
"description": "Example: switch statement snippet"
|
|
},
|
|
"Example-Advanced Workflow": {
|
|
"prefix": "ex-advanced workflow",
|
|
"body": [
|
|
"<#",
|
|
".Synopsis",
|
|
"\tShort description",
|
|
".DESCRIPTION",
|
|
"\tLong description",
|
|
".EXAMPLE",
|
|
"\tExample of how to use this workflow",
|
|
".EXAMPLE",
|
|
"\tAnother example of how to use this workflow",
|
|
".INPUTS",
|
|
"\tInputs to this workflow (if any)",
|
|
".OUTPUTS",
|
|
"\tOutput from this workflow (if any)",
|
|
".NOTES",
|
|
"\tGeneral notes",
|
|
".FUNCTIONALITY",
|
|
"\tThe functionality that best describes this workflow",
|
|
"#>",
|
|
"workflow ${name:Verb-Noun} {",
|
|
"\t[CmdletBinding(DefaultParameterSetName='Parameter Set 1',",
|
|
"\t HelpUri = 'http://www.microsoft.com/',",
|
|
"\t ConfirmImpact='Medium')]",
|
|
"\t[Alias()]",
|
|
"\t[OutputType([String])]",
|
|
"\tparam (",
|
|
"\t\t# Param1 help description",
|
|
"\t\t[Parameter(Mandatory=\\$true, ",
|
|
"\t\t Position=0,",
|
|
"\t\t ParameterSetName='Parameter Set 1')]",
|
|
"\t\t[ValidateNotNull()]",
|
|
"\t\t[Alias(\"p1\")] ",
|
|
"\t\t\\$Param1,",
|
|
"",
|
|
"\t\t# Param2 help description",
|
|
"\t\t[int]",
|
|
"\t\t\\$Param2",
|
|
"\t)",
|
|
"",
|
|
"\t# Saves (persists) the current workflow state and output",
|
|
"\t# Checkpoint-Workflow",
|
|
"\t# Suspends the workflow",
|
|
"\t# Suspend-Workflow",
|
|
"",
|
|
"\t# Workflow common parameters are available as variables such as:",
|
|
"\t\\$PSPersist ",
|
|
"\t\\$PSComputerName",
|
|
"\t\\$PSCredential",
|
|
"\t\\$PSUseSsl",
|
|
"\t\\$PSAuthentication",
|
|
"",
|
|
"\t# Workflow runtime information can be accessed by using the following variables:",
|
|
"\t\\$Input",
|
|
"\t\\$PSSenderInfo",
|
|
"\t\\$PSWorkflowRoot",
|
|
"\t\\$JobCommandName",
|
|
"\t\\$ParentCommandName",
|
|
"\t\\$JobId",
|
|
"\t\\$ParentJobId",
|
|
"\t\\$WorkflowInstanceId",
|
|
"\t\\$JobInstanceId",
|
|
"\t\\$ParentJobInstanceId",
|
|
"\t\\$JobName",
|
|
"\t\\$ParentJobName",
|
|
"",
|
|
"\t# Set the progress message ParentActivityId",
|
|
"\t\\$PSParentActivityId",
|
|
"",
|
|
"\t# Preference variables that control runtime behavior",
|
|
"\t\\$PSRunInProcessPreference",
|
|
"\t\\$PSPersistPreference",
|
|
"}"
|
|
],
|
|
"description": "Example: advanced workflow snippet"
|
|
},
|
|
"Class": {
|
|
"prefix": "class",
|
|
"body": [
|
|
"class ${1:ClassName} {",
|
|
"\t$0",
|
|
"}"
|
|
],
|
|
"description": "Class definition snippet"
|
|
},
|
|
"Constructor": {
|
|
"prefix": "ctor",
|
|
"body": [
|
|
"${1:ClassName}(${2:OptionalParameters}) {",
|
|
"\t$0",
|
|
"}"
|
|
],
|
|
"description": "Class constructor definition snippet"
|
|
},
|
|
"Hidden Property": {
|
|
"prefix": "proph",
|
|
"body": [
|
|
"hidden [${1:string}] $${0:PropertyName}"
|
|
],
|
|
"description": "Class hidden property definition snippet"
|
|
},
|
|
"Property": {
|
|
"prefix": "prop",
|
|
"body": [
|
|
"[${1:string}] $${0:PropertyName}"
|
|
],
|
|
"description": "Class property definition snippet"
|
|
},
|
|
"Method": {
|
|
"prefix": "method",
|
|
"body": [
|
|
"[${1:void}] ${2:MethodName}($${3:OptionalParameters}) {",
|
|
"\t$0",
|
|
"}"
|
|
],
|
|
"description": "Class method definition snippet"
|
|
},
|
|
"Enum": {
|
|
"prefix": "enum",
|
|
"body": [
|
|
"enum ${1:EnumName} {",
|
|
"\t$0",
|
|
"}"
|
|
],
|
|
"description": "Enum definition snippet"
|
|
},
|
|
"Cmdlet": {
|
|
"prefix": "cmdlet",
|
|
"body": [
|
|
"function ${1:Verb-Noun} {",
|
|
"\t[CmdletBinding()]",
|
|
"\tparam (",
|
|
"\t\t$0",
|
|
"\t)",
|
|
"\t",
|
|
"\tbegin {",
|
|
"\t}",
|
|
"\t",
|
|
"\tprocess {",
|
|
"\t}",
|
|
"\t",
|
|
"\tend {",
|
|
"\t}",
|
|
"}"
|
|
],
|
|
"description": "Script cmdlet definition snippet"
|
|
},
|
|
"Function-Advanced": {
|
|
"prefix": "function-advanced",
|
|
"body": [
|
|
"function ${1:Verb-Noun} {",
|
|
"\t[CmdletBinding()]",
|
|
"\tparam (",
|
|
"\t\t$0",
|
|
"\t)",
|
|
"\t",
|
|
"\tbegin {",
|
|
"\t}",
|
|
"\t",
|
|
"\tprocess {",
|
|
"\t}",
|
|
"\t",
|
|
"\tend {",
|
|
"\t}",
|
|
"}"
|
|
],
|
|
"description": "Script advanced function definition snippet"
|
|
},
|
|
"Cmdlet-Comment-Help": {
|
|
"prefix": "comment-help",
|
|
"body": [
|
|
"<#",
|
|
".SYNOPSIS",
|
|
"\tShort description",
|
|
".DESCRIPTION",
|
|
"\tLong description",
|
|
".EXAMPLE",
|
|
"\tPS C:\\> <example usage>",
|
|
"\tExplanation of what the example does",
|
|
".INPUTS",
|
|
"\tInputs (if any)",
|
|
".OUTPUTS",
|
|
"\tOutput (if any)",
|
|
".NOTES",
|
|
"\tGeneral notes",
|
|
"#>"
|
|
],
|
|
"description": "Comment-based help snippet"
|
|
},
|
|
"Parameter": {
|
|
"prefix": "parameter",
|
|
"body": [
|
|
"# ${1:Parameter help description}",
|
|
"[Parameter(${2:AttributeValues})]",
|
|
"[${3:ParameterType}]",
|
|
"$${0:ParameterName}"
|
|
],
|
|
"description": "Parameter declaration snippet"
|
|
},
|
|
"Parameter-Path": {
|
|
"prefix": "parameter-path",
|
|
"body": [
|
|
"# Specifies a path to one or more locations.",
|
|
"[Parameter(Mandatory=\\$true,",
|
|
" Position=${1:0},",
|
|
" ParameterSetName=\"${2:ParameterSetName}\",",
|
|
" ValueFromPipeline=\\$true,",
|
|
" ValueFromPipelineByPropertyName=\\$true,",
|
|
" HelpMessage=\"Path to one or more locations.\")]",
|
|
"[Alias(\"PSPath\")]",
|
|
"[ValidateNotNullOrEmpty()]",
|
|
"[string[]]",
|
|
"$${3:ParameterName}$0"
|
|
],
|
|
"description": "Parameter declaration snippet for Path parameter that does not accept wildcards. Do not use with parameter-literalpath."
|
|
},
|
|
"Parameter-Path-Wildcards": {
|
|
"prefix": "parameter-path-wildcards",
|
|
"body": [
|
|
"# Specifies a path to one or more locations. Wildcards are permitted.",
|
|
"[Parameter(Mandatory=\\$true,",
|
|
" Position=${1:Position},",
|
|
" ParameterSetName=\"${2:ParameterSetName}\",",
|
|
" ValueFromPipeline=\\$true,",
|
|
" ValueFromPipelineByPropertyName=\\$true,",
|
|
" HelpMessage=\"Path to one or more locations.\")]",
|
|
"[ValidateNotNullOrEmpty()]",
|
|
"[SupportsWildcards()]",
|
|
"[string[]]",
|
|
"$${3:ParameterName}$0"
|
|
],
|
|
"description": "Parameter declaration snippet for Path parameter that accepts wildcards. Add parameter-literalpath to handle paths with embedded wildcard chars."
|
|
},
|
|
"Parameter-LiteralPath": {
|
|
"prefix": "parameter-literalpath",
|
|
"body": [
|
|
"# Specifies a path to one or more locations. Unlike the Path parameter, the value of the LiteralPath parameter is",
|
|
"# used exactly as it is typed. No characters are interpreted as wildcards. If the path includes escape characters,",
|
|
"# enclose it in single quotation marks. Single quotation marks tell Windows PowerShell not to interpret any",
|
|
"# characters as escape sequences.",
|
|
"[Parameter(Mandatory=\\$true,",
|
|
" Position=${1:0},",
|
|
" ParameterSetName=\"${2:LiteralPath}\",",
|
|
" ValueFromPipelineByPropertyName=\\$true,",
|
|
" HelpMessage=\"Literal path to one or more locations.\")]",
|
|
"[Alias(\"PSPath\")]",
|
|
"[ValidateNotNullOrEmpty()]",
|
|
"[string[]]",
|
|
"$${2:LiteralPath}$0"
|
|
],
|
|
"description": "Parameter declaration snippet for a LiteralPath parameter"
|
|
},
|
|
"DSC Ensure Enum": {
|
|
"prefix": "DSC Ensure enum",
|
|
"body": [
|
|
"enum Ensure {",
|
|
"\tAbsent",
|
|
"\tPresent",
|
|
"}"
|
|
],
|
|
"description": "DSC Ensure enum definition snippet"
|
|
},
|
|
"DSC Resource Provider (class-based)": {
|
|
"prefix": "DSC resource provider (class-based)",
|
|
"body": [
|
|
"[DscResource()]",
|
|
"class ${ResourceName:NameOfResource} {",
|
|
"\t[DscProperty(Key)]",
|
|
"\t[string] $${PropertyName:KeyName}",
|
|
"\t",
|
|
"\t# Gets the resource's current state.",
|
|
"\t[${ResourceName:NameOfResource}] Get() {",
|
|
"\t\t$0",
|
|
"\t\treturn \\$this",
|
|
"\t}",
|
|
"\t",
|
|
"\t# Sets the desired state of the resource.",
|
|
"\t[void] Set() {",
|
|
"\t\t",
|
|
"\t}",
|
|
"\t",
|
|
"\t# Tests if the resource is in the desired state.",
|
|
"\t[bool] Test() {",
|
|
"\t\t",
|
|
"\t}",
|
|
"}"
|
|
],
|
|
"description": "Class-based DSC resource provider snippet"
|
|
},
|
|
"DSC Resource Provider (function-based)": {
|
|
"prefix": "DSC resource provider (function-based)",
|
|
"body": [
|
|
"function Get-TargetResource {",
|
|
"\tparam (",
|
|
"\t)",
|
|
"\t",
|
|
"\t$0",
|
|
"}",
|
|
"function Set-TargetResource {",
|
|
"\tparam (",
|
|
"\t)",
|
|
"\t",
|
|
"}",
|
|
"function Test-TargetResource {",
|
|
"\tparam (",
|
|
"\t)",
|
|
"\t",
|
|
"}"
|
|
],
|
|
"description": "Function-based DSC resource provider snippet"
|
|
},
|
|
"comment block": {
|
|
"prefix": "comment",
|
|
"body": [
|
|
"<#",
|
|
" # $0",
|
|
" #>"
|
|
],
|
|
"description": "Comment block snippet"
|
|
},
|
|
"do-until": {
|
|
"prefix": "do-until",
|
|
"body": [
|
|
"do {",
|
|
"\t$0",
|
|
"} until (${1:condition})"
|
|
],
|
|
"description": "do-until loop snippet"
|
|
},
|
|
"do-while": {
|
|
"prefix": "do-while",
|
|
"body": [
|
|
"do {",
|
|
"\t$0",
|
|
"} while (${1:condition})"
|
|
],
|
|
"description": "do-while loop snippet"
|
|
},
|
|
"while": {
|
|
"prefix": "while",
|
|
"body": [
|
|
"while (${1:condition}) {",
|
|
"\t$0",
|
|
"}"
|
|
],
|
|
"description": "while loop snippet"
|
|
},
|
|
"for": {
|
|
"prefix": "for",
|
|
"body": [
|
|
"for ($${1:i} = 0; $${1:i} -lt $${2:array}.Count; $${1:i}++) {",
|
|
"\t$0",
|
|
"}"
|
|
],
|
|
"description": "for loop snippet"
|
|
},
|
|
"for-reversed": {
|
|
"prefix": "forr",
|
|
"body": [
|
|
"for ($${1:i} = $${2:array}.Count - 1; $${1:i} -ge 0 ; $${1:i}--) {",
|
|
"\t$0",
|
|
"}"
|
|
],
|
|
"description": "reversed for loop snippet"
|
|
},
|
|
"foreach": {
|
|
"prefix": "foreach",
|
|
"body": [
|
|
"foreach ($${1:item} in $${2:collection}) {",
|
|
"\t$0",
|
|
"}"
|
|
],
|
|
"description": "foreach loop snippet"
|
|
},
|
|
"function": {
|
|
"prefix": "function",
|
|
"body": [
|
|
"function ${1:FunctionName} {",
|
|
"\tparam (",
|
|
"\t\t${2:OptionalParameters}",
|
|
"\t)",
|
|
"\t$0",
|
|
"}"
|
|
],
|
|
"description": "Function definition snippet that contains a param block"
|
|
},
|
|
"Function-Inline": {
|
|
"prefix": "Function-Inline",
|
|
"body": [
|
|
"function ${1:FunctionName} (${2:OptionalParameters}) {",
|
|
"\t$0",
|
|
"}"
|
|
],
|
|
"description": "Function definition snippet that does not contain a param block, but defines parameters inline. This syntax is commonly used in other lanaguages"
|
|
},
|
|
"if": {
|
|
"prefix": "if",
|
|
"body": [
|
|
"if (${1:condition}) {",
|
|
"\t$0",
|
|
"}"
|
|
],
|
|
"description": "if statement snippet"
|
|
},
|
|
"elseif": {
|
|
"prefix": "elseif",
|
|
"body": [
|
|
"elseif (${1:condition}) {",
|
|
"\t$0",
|
|
"}"
|
|
],
|
|
"description": "elseif statement snippet"
|
|
},
|
|
"else": {
|
|
"prefix": "else",
|
|
"body": [
|
|
"else {",
|
|
"\t$0",
|
|
"}"
|
|
],
|
|
"description": "else statement snippet"
|
|
},
|
|
"switch": {
|
|
"prefix": "switch",
|
|
"body": [
|
|
"switch (${1:\\$x}) {",
|
|
"\t${2:condition} { $0 }",
|
|
"\tDefault {}",
|
|
"}"
|
|
],
|
|
"description": "switch statement snippet"
|
|
},
|
|
"try-catch": {
|
|
"prefix": "try",
|
|
"body": [
|
|
"try {",
|
|
"\t$0",
|
|
"}",
|
|
"catch {",
|
|
"\t",
|
|
"}"
|
|
],
|
|
"description": "try-catch snippet"
|
|
},
|
|
"try-catch-finally": {
|
|
"prefix": "trycf",
|
|
"body": [
|
|
"try {",
|
|
"\t$0",
|
|
"}",
|
|
"catch {",
|
|
"\t",
|
|
"}",
|
|
"finally {",
|
|
"\t",
|
|
"}"
|
|
],
|
|
"description": "try-catch-finally snippet"
|
|
},
|
|
"try-finally": {
|
|
"prefix": "tryf",
|
|
"body": [
|
|
"try {",
|
|
"\t$0",
|
|
"}",
|
|
"finally {",
|
|
"\t",
|
|
"}"
|
|
],
|
|
"description": "try-finally snippet"
|
|
},
|
|
"Workflow": {
|
|
"prefix": "workflow",
|
|
"body": [
|
|
"workflow ${name:Verb-Noun} {",
|
|
"\tparam (",
|
|
"\t)",
|
|
"",
|
|
"\t$0",
|
|
"}"
|
|
],
|
|
"description": "workflow snippet"
|
|
},
|
|
"Workflow ForEachParallel": {
|
|
"prefix": "workflow foreach-parallel",
|
|
"body": [
|
|
"foreach -parallel ($${variable:item} in $${collection:collection}) {",
|
|
"\t$0",
|
|
"}"
|
|
],
|
|
"description": "foreach-parallel snippet (for use inside a workflow)"
|
|
},
|
|
"Workflow InlineScript": {
|
|
"prefix": "workflow inlinescript",
|
|
"body": [
|
|
"inlineScript {",
|
|
"\t$0",
|
|
"}"
|
|
],
|
|
"description": "inlinescript snippet (for use inside a workflow)"
|
|
},
|
|
"Workflow Parallel": {
|
|
"prefix": "workflow parallel",
|
|
"body": [
|
|
"parallel {",
|
|
"\t$0",
|
|
"}"
|
|
],
|
|
"description": "parallel snippet (for use inside a workflow)"
|
|
},
|
|
"Workflow Sequence": {
|
|
"prefix": "workflow sequence",
|
|
"body": [
|
|
"sequence {",
|
|
"\t$0",
|
|
"}"
|
|
],
|
|
"description": "sequence snippet (for use inside a workflow)"
|
|
},
|
|
"Suppress PSScriptAnalyzer Rule": {
|
|
"prefix": "suppress-message-rule",
|
|
"description": "Suppress a built-in PSScriptAnalyzer rule using the SuppressMessageAttribute",
|
|
"body": [
|
|
"[Diagnostics.CodeAnalysis.SuppressMessageAttribute('${1:PSUseDeclaredVarsMoreThanAssignments}', '')]"
|
|
]
|
|
},
|
|
"Suppress PSScriptAnalyzer Rule on Parameter": {
|
|
"prefix": "suppress-message-rule-for-parameter",
|
|
"description": "Suppress a built-in PSScriptAnalyzer rule on a parameter using the SuppressMessageAttribute",
|
|
"body": [
|
|
"[Diagnostics.CodeAnalysis.SuppressMessageAttribute('${1:PSUseDeclaredVarsMoreThanAssignments}', '${2:ParamName}')]"
|
|
]
|
|
},
|
|
"Suppress PSScriptAnalyzer Rule in Scope": {
|
|
"prefix": "suppress-message-rule-for-scope",
|
|
"description": "Suppress a built-in PSScriptAnalyzer rule for functions or classes in a specific scope using the SuppressMessageAttribute",
|
|
"body": [
|
|
"[Diagnostics.CodeAnalysis.SuppressMessageAttribute('${1:PSProvideDefaultParameterValue}', '', Scope='Function', Target='${2:*}')]"
|
|
]
|
|
},
|
|
"PSCustomObject": {
|
|
"prefix": "PSCustomObject",
|
|
"body": [
|
|
"[PSCustomObject]@{",
|
|
"\t${1:Name} = ${2:Value}",
|
|
"}"
|
|
],
|
|
"description": "Creates a PSCustomObject"
|
|
},
|
|
"Hashtable": {
|
|
"prefix": "Hashtable",
|
|
"body": [
|
|
"\\$${1:Var} = @{",
|
|
"\t${2:Name} = ${3:Value}",
|
|
"}"
|
|
],
|
|
"description": "Creates a Hashtable"
|
|
},
|
|
"Region Block": {
|
|
"prefix": "#region",
|
|
"body": [
|
|
"#region ${1}",
|
|
"$0",
|
|
"#endregion"
|
|
],
|
|
"description": "Region Block for organizing and folding of your code"
|
|
}
|
|
}
|