问题
I am using Microsoft Visual Studio 2008 Visual Basic, and am creating a custom PowerShell Cmdlet.
How do I detect if either the -Verbose
or -Debug
parameters are used?
I have tried If Debug.IsPresent Then
, but that does not appear to work.
回答1:
You have to examine the parameters that are passed into the cmdlet. Use the $PSBoundParameters
automatic variable to determine which parameters were specified.
For more information, see: Get-Help -Name about_Automatic_Variables;
回答2:
It is not VB.Net, but here is a solution in C# which should translate to VB.Net with ease
来源:https://stackoverflow.com/questions/20815693/detect-debug-and-verbose-function-parameters-in-vb-net