Here's my script (test.ps1):
[CmdLetBinding()]
Param
(
[parameter(Mandatory=$true)][string]$environment,
[switch][bool]$continue=$true
)
Write-Host $environment
Write-Host $continue
Question:
If I invoke this script by giving an argument which is a substring of the parameter I specified in the script like this: PS> .\test.ps1 -envi:blah, PowerShell doesn't seem to check the argument name. I want PowerShell to enforce parameter spelling, i.e., it should only accept -environment which matches the parameter name in the script. For anything else, it should raise an exception. Is that doable? How do I do that?
Thanks.
Select -Excould mean-ExpandPropertyor-ExcludeProperty.-Expand-Exc, while not very descriptive, only have one parameter they could match each. PowerShell is only trying to do you a favour but wont allow a mistake to occur.Select-Object : Parameter cannot be processed because the parameter name 'ex' is ambiguous