I have the following Param block at the start of my script:
Param
(
[Parameter(Mandatory = $true)]
[ValidateScript({Test-Path $_ -PathType Leaf})]
[string]$Config,
[switch]$OverThresholdOnly,
[switch]$SendEmail,
[switch]$Debug
)
When I run the script I get the error:
"A parameter with the name 'Debug' was defined multiple times for this command. At line:1 char:1"
Line:1 and char:1 is the start of the Param block.
If I change the $Debug to $Verbose I get the same error about Verbose. I've tried putting the $debug at the top of the Param block with the same error.
If I remove the [ValidateScript] section it works fine.
Can anybody tell me why it does this? Why [ValidateScript] is using $Debug and how to get around this short of renaming the variable?