none
Set-Mailbox AcceptMessagesOnlyFrom powersell command is not working as expected [C# , Windows Application] RRS feed

  • Question

  • I'm trying to connect programmatically in C# to Exchange 2007 server via a Powershell runspace to AcceptMessagesOnlyFrom list of the mailbox (Room mailbox/resource mailbox) .

    The code is executing without any error, but the user is not getting added to the list.

     

    Here is my code

     

                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);

     

     

    Could someone please look at my code and let me know how I would go about fixing it so that the Set-Mailbox command runs successfully, and user name should get added to AcceptMessagesOnlyFrom list of the MeetingRoom(Mailbox) in exchange server.

     

    Any help would be greatly appreciated

     

    *Room mailbox: This is a mailbox to be assigned specifically to Meeting Rooms.

    Its associated user account will be disabled in Active Directory.

    • Moved by Leo Liu - MSFT Tuesday, November 8, 2011 7:52 AM Moved for better support. (From:Visual C# General)
    Monday, November 7, 2011 5:50 AM

Answers

All replies