C# - Update multi valued attributes in Exchange 2010 RRS feed

  • General discussion

  • Hello All,

    I have a c# application where in I need to add more values or remove value of a multi valued attribute of a mailbox.

    I have a mailbox called 'MyMailbox@MyDomain.com'. I would like to manage the 'AcceptMessagesOnlyFrom' multi valued property of this mail box.

    I can execute

    //Assume runspace was created with all correct values...
    using (PowerShell p = PowerShell.Create())
                    p.Runspace = _runSpace;
                    PSCommand pscmd = new PSCommand();
                    pscmd.AddParameter("Identity", "MyMailbox@MyDomain.com");                
                    IList<object> values = new List<object>();                
    pscmd.AddParameter("AcceptMessagesOnlyFrom", values);
                    p.Commands = pscmd;
                    ICollection<PSObject> psObjects = p.Invoke();

    If I execute "MyMailbox2" will added as value to 'AcceptMessagesOnlyFrom' attribute. If I comment out MyMailbox2 and un comment MyMailbox3 and execute, 'AcceptMessagesOnlyFrom' attribute will now have MyMailbox3 as value i.e it has removed 'MyMailbox2'.

    I would like to add or remove the values and not replace values as described here Multivalued Properties in Exchange 2010.

    How can I do the same in c# application ?



    Sunday, April 7, 2013 7:53 AM

All replies

  • Hi - got it. I need to execute it as a script and not as command like below:-

    String CommandScript = "Set-mailbox -Identity MyMailbox@MyDomain.com -AcceptMessagesOnlyFrom @{ADD=\"MyMailbox2@MyDomain.com"}";

    This works. Thanks!


    Sunday, April 7, 2013 8:04 AM