从C#Custom Cmdlet中调用Read-Host cmdlet

时间:2013-03-26 19:26:31

标签: c# powershell input cmdlet

我正在编写一组需要Oauth2身份验证的Powershell Cmdlet。我现在能够打开一个新的浏览器窗口并且用户复制出访问身份验证代码以传回cmdlet。但是,这意味着我必须有一个单独的cmdlet,现在接受Auth Code作为输入。

有没有办法调用Read-Host?我已经尝试了instructions但是尽管被列出了,ReadHostCommand没有显示在Microsoft.PowerShell.Commands命名空间下,但像WhereObjectCommand这样的东西是。

我已经尝试过Console.ReadLine()但是在运行Cmdlet时它被忽略了。

1 个答案:

答案 0 :(得分:4)

ReadHostCommand位于Microsoft.PowerShell.Commands命名空间中,但您必须引用Microsoft.PowerShell.Commands.Utility.dll程序集。

相关问题