I have a custom C# PowerShell Cmdlet (inheriting from the Cmdlet base class) and I want to be able to identify if the "-Verbose" parameter was specified when running the Cmdlet. I realize that WriteVerbose will output when the -Verbose parameter is specified, but I would like to actually do some other code when -Verbose is specified (i.e. not output the Console.Write values when -Verbose is specified).
Thanks,
John
Check the cmdlet's bound parameters like so:
if (this.MyInvocation.BoundParameters.ContainsKey("Verbose"))
{
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With