Skip to content

Commit f944156

Browse files
Update PowerShellScriptParameters.md
Update PS snippets
1 parent fa55308 commit f944156

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

Snippets/PowerShellScriptParameters.md

+12-6
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,23 @@ param
77
(
88
[Parameter(Mandatory = $true,
99
Position = 1,
10-
HelpMessage = 'Please specify the folder that...')]
11-
[String]$variableName1,
10+
HelpMessage = 'Please specify a valid Windows folder path')]
11+
[ValidatePattern('^([a-zA-Z]:\\)([^\\/:*?<>"|]+\\)*[^\\/:*?<>"|\s]+$')] # regex pattern to ensure the end user provides a folder path matching common Windows folder path convention
12+
[String]$path,
1213
[Parameter(Mandatory = $true,
1314
Position = 2,
14-
HelpMessage = 'Please specify the output directory for...')]
15-
[String]$variableName2,
15+
HelpMessage = 'This is a parameter that is looking for a case non-specific set of values, and nothing else')]
16+
[ValidateSet('thing1', 'thing2', 'thing3', 'thing4', IgnoreCase = $true)]
17+
[String]$SetOfValues,
1618
[Parameter(Mandatory = $true,
1719
Position = 3,
18-
HelpMessage = 'Choose the number of...')]
20+
HelpMessage = 'This is an example of a parameter that needs a number between 1 and 10')]
1921
[ValidateRange(1, 10)]
20-
[String]$variableName3 = '3'
22+
[int]$Number = '3',
23+
[Parameter(Position = 4,
24+
HelpMessage = 'This parameter is looking for only a positive integer')]
25+
[ValidateRange("Positive")]
26+
[int]$PositiveNumberOnly
2127
)
2228
```
2329

0 commit comments

Comments
 (0)