我正在尋找一種方法來爲會議室(郵箱)設置AcceptMessagesOnlyFrom。我正在使用C#代碼(Windows應用程序)執行Exchange 2007 Powershell命令。Set-Mailbox AcceptMessagesOnlyFrom powersell命令不能按預期工作
這裏是我的代碼
RunspaceConfiguration rc = RunspaceConfiguration.Create();
PSSnapInException snapEx = null;
PSSnapInInfo info = rc.AddPSSnapIn("Microsoft.Exchange.Management.PowerShell.Admin", out snapEx);
Runspace r = RunspaceFactory.CreateRunspace(rc);
r.Open();
RunspaceInvoke ri = new RunspaceInvoke(r);
string str = "Set-Mailbox -Identity '" + MeetingRoomName + "' -AcceptMessagesOnlyFrom ((Get-Mailbox -identity '" + MeetingRoomName + "').AcceptMessagesOnlyFrom + " + strUser + ")";
ICollection<PSObject> results = ri.Invoke(str);
該命令從PowerShell的正常使用,但不能從C#代碼.The沒有任何錯誤的執行,但用戶不獲取添加到列表中。
任何幫助將不勝感激。
難道你需要以管理員身份運行VS或C#嗎? –
其實我沒有太多的知識。你能告訴我如何以管理員身份運行VS或C#嗎? – user964481