Running a powershell command in C# errors with, “Cannot invoke this function because the current host does not implement it”

后端 未结 1 924
深忆病人
深忆病人 2020-12-19 17:47

I have an application that I use to run Exchange Powershell commands inside C# code like below. This is an example of the relevant lines I use to run the powershell command

相关标签:
1条回答
  • 2020-12-19 17:58

    If that command would normally prompt for confirmation then you will need to either:

    • Set -Confirm:$false as a parameter (and possibly -Force as well)
    • Set $ConfirmPreference = "None" before calling Set-Mailbox (and possibly -Force too)
    • Create a Host and implement the Confirm functionality ;-)
    0 讨论(0)
提交回复
热议问题