locked
Powershell New-DistributionGroup how to convert string[] to MultiValuedProperty RRS feed

  • Question

  • I need to be able to convert a string array to MultiValuedProperty so I can pass this as a parameter for PSCommand. Any idea on how to do this?

    Basically this is what I have come up with:

    var members = new MultiValuedProperty<RecipientWithAdUserGroupIdParameter<RecipientIdParameter>>();
                    foreach (string s in group.Members)
                    {
                        if (!string.IsNullOrEmpty(s))
                        {
                        }
                    }
    
                    cmd.AddParameter("Members", members);

    but the problem is where i need to add a new value. It appears RecipientWithAdUserGroupIdParameter<RecipientIdParameter> does not have a ADD method. It only has these methods:

    Equals
    GetHashCode
    GetObjects<>
    GetType
    ToString

    Friday, January 25, 2013 2:43 PM

Answers

  • If your using Remote Powershell you shouldn't be using the Strong Types (they shouldn't be available anyway) eg something like this should work

                    Command newDG = new Command("New-DistributionGroup");
                    newDG.Parameters.Add(new CommandParameter("Name", "Test-DL"));
                    newDG.Parameters.Add(new CommandParameter("Members", new String[]{"glen@domain.com","fred@domain.com"}));
                    ps.Commands.AddCommand(newDG);
    
    Cheers
    Glen
    • Marked as answer by Quadrantids Wednesday, March 6, 2013 8:59 PM
    Wednesday, January 30, 2013 4:48 AM