|
228 | 228 | "Example-Path Processing": {
|
229 | 229 | "prefix": "ex-path processing",
|
230 | 230 | "body": [
|
| 231 | + "# Modify [CmdletBinding()] to [CmdletBinding(SupportsShouldProcess=$true, DefaultParameterSetName='Path')]", |
231 | 232 | "$paths = @()",
|
232 | 233 | "if ($psCmdlet.ParameterSetName -eq 'Path') {",
|
233 | 234 | "\tforeach ($aPath in $Path) {",
|
234 | 235 | "\t\tif (!(Test-Path -Path $aPath)) {",
|
235 |
| - "\t\t\t$ex = New-Object System.Management.Automation.ItemNotFoundException \"Cannot find path '$Path' because it does not exist.\"", |
| 236 | + "\t\t\t$ex = New-Object System.Management.Automation.ItemNotFoundException \"Cannot find path '$aPath' because it does not exist.\"", |
236 | 237 | "\t\t\t$category = [System.Management.Automation.ErrorCategory]::ObjectNotFound",
|
237 |
| - "\t\t\t$errRecord = New-Object System.Management.Automation.ErrorRecord $ex,'PathNotFound',$category,$Path", |
| 238 | + "\t\t\t$errRecord = New-Object System.Management.Automation.ErrorRecord $ex,'PathNotFound',$category,$aPath", |
238 | 239 | "\t\t\t$psCmdlet.WriteError($errRecord)",
|
239 | 240 | "\t\t\tcontinue",
|
240 | 241 | "\t\t}",
|
|
246 | 247 | "else {",
|
247 | 248 | "\tforeach ($aPath in $LiteralPath) {",
|
248 | 249 | "\t\tif (!(Test-Path -LiteralPath $aPath)) {",
|
249 |
| - "\t\t\t$ex = New-Object System.Management.Automation.ItemNotFoundException \"Cannot find path '$LiteralPath' because it does not exist.\"", |
| 250 | + "\t\t\t$ex = New-Object System.Management.Automation.ItemNotFoundException \"Cannot find path '$aPath' because it does not exist.\"", |
250 | 251 | "\t\t\t$category = [System.Management.Automation.ErrorCategory]::ObjectNotFound",
|
251 |
| - "\t\t\t$errRecord = New-Object System.Management.Automation.ErrorRecord $ex,'PathNotFound',$category,$LiteralPath", |
| 252 | + "\t\t\t$errRecord = New-Object System.Management.Automation.ErrorRecord $ex,'PathNotFound',$category,$aPath", |
252 | 253 | "\t\t\t$psCmdlet.WriteError($errRecord)",
|
253 | 254 | "\t\t\tcontinue",
|
254 | 255 | "\t\t}",
|
|
0 commit comments