In Custom C# PowerShell Cmdlet Identify If -Verbose Was Specified In Custom C# PowerShell Cmdlet Identify If -Verbose Was Specified powershell powershell

In Custom C# PowerShell Cmdlet Identify If -Verbose Was Specified


Check the cmdlet's bound parameters like so:

if (this.MyInvocation.BoundParameters.ContainsKey("Verbose")){}


After much digging about, this works for me.Visual Studio 2013, Powershell 3.0C# cmdlet using the PsCmdlet namespace.import-module .\mytest.dll, then mytest -verbose

blnVerbose = this.MyInvocation.Line.ToLower().Contains("-verbose");