如何设置确认参数? [英] How to set the confirm parameter?

查看:96
本文介绍了如何设置确认参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个示例程序来执行dismount-database cmdlet,但是当我向我的命令添加confirm参数时,我遇到异常。这是怎么做的。我的示例代码如下:

命令EMSMntCommand = new命令("Dismount-Database");
EMSMntCommand.Parameters.Add("Identity","Mailbox Database") ;
EMSMntCommand.Parameters.Add([确认:$ FALSE"); //我试过的变种是EMSMntCommand.Parameters.Add(" Confirm"," FALSE");
/ *我收到异常,因为当前参数'确认'需要将'System.String'转换为'System.String'类型'System.Management.Automation.SwitchParameter'。 "}
* /
result2 = ems.PipelineInvoke(EMSMntCommand);

我应该如何以编程方式卸载数据库。

我的shell时我执行命令

dismount-database -Identity'Mailbox-Database' - 确认:$ FALSE

它工作正常

任何帮助都会是感谢。

感谢

DK

I am writing a sample program to execute the dismount-database cmdlet, but i am getting exception when i add confirm parameter to my command.  What is the way to do it.  My sample code is as below.

Command EMSMntCommand = new Command("Dismount-Database");
EMSMntCommand.Parameters.Add("Identity", "Mailbox Database");
EMSMntCommand.Parameters.Add("Confirm:$FALSE"); //variations i tried are EMSMntCommand.Parameters.Add("Confirm","FALSE");
/* I am getting the exception as
ex = {"Cannot convert 'System.String' to the type 'System.Management.Automation.SwitchParameter' required by parameter 'Confirm'. "}
*/
results2 = ems.PipelineInvoke(EMSMntCommand);

How should i dismount-database programatically.

I the shell when i execute the command

dismount-database -Identity 'Mailbox-Database' -Confirm:$FALSE

It works fine

Any help would be appreciated.

Thanks

DK

推荐答案

尝试:


Try:

EMSMntCommand.Parameters.Add("Confirm:",


FALSE);




Or

EMSMntCommand.Parameters.Add("Confirm:", '


FALSE');


Karl

Karl


这篇关于如何设置确认参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆