I have a C# script to mail-enable a distribution group in Exchange. I have tried the following code, which works currently:
Command command = new Command("Enable-DistributionGroup -Identity '#Test DL'");
psInstance.Commands.AddCommand(command);
The above code works, and will return a string with the name of the distribution group. Upon checking the distribution group, it has become mail-enabled.
The below code does not work, and returns an empty string:
Command command = new Command("Enable-DistributionGroup").AddParameter("Identity", "#Test DL");
psInstance.Commands.AddCommand(command);
Am I using the AddParameter function incorrectly?