检测 VB.NET 中的 -Debug 和 -Verbose 函数参数 [英] Detect -Debug and -Verbose function parameters in VB.NET
本文介绍了检测 VB.NET 中的 -Debug 和 -Verbose 函数参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用 Microsoft Visual Studio 2008 Visual Basic,并且正在创建自定义 PowerShell Cmdlet.
I am using Microsoft Visual Studio 2008 Visual Basic, and am creating a custom PowerShell Cmdlet.
如何检测是否使用了 -Verbose
或 -Debug
参数?我试过 If Debug.IsPresent Then
,但这似乎不起作用.
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.
推荐答案
您必须检查传递到 cmdlet 的参数.使用 $PSBoundParameters
自动变量来确定指定了哪些参数.
You have to examine the parameters that are passed into the cmdlet. Use the $PSBoundParameters
automatic variable to determine which parameters were specified.
更多信息,请参见:Get-Help -Name about_Automatic_Variables;
这篇关于检测 VB.NET 中的 -Debug 和 -Verbose 函数参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文