Per Technet - Add or Remove Email Addresses for a Mailbox, using the PowerShell console, the following successfully removes an email alias from a mailbox :
Set-Mailbox "GenMgr" -EmailAddresses @{remove="GenMgr@domain.com"}
However, invoking the PSCommand object below via remote runspace throws a System.Management.Automation.RemoteException error.
command.AddCommand("Set-Mailbox");
command.AddParameter("Identity", "GenMgr");
command.AddParameter("EmailAddresses", "@{remove='GenMgr@domain.com'}");
powershell.Commands = command;
powershell.Invoke();
System.Management.Automation.RemoteException: Cannot process argument transformation on parameter 'EmailAddresses'. Cannot convert value "@{remove='GenMgr@domain.com'}" to type "Microsoft.Exchange.Data.ProxyAddressCollection". Error: "The address '@{remove='GenMgr@domain.com'}' is invalid: "@{remove='GenMgr@domain.com'}" isn't a valid SMTP address. The domain name can't contain spaces and it has to have a prefix and a suffix, such as example.com."
It seems to me the problem is with the 'remove' instruction in the EmailAddresses parameter.
How do I use C# and the PowerShell remote runspace on Windows 8 to get Exchange 2010 to remove an email alias?