I’m trying to add several proxy addresses to all user accounts on the domain, I can do via exporting the proxy addresses and then importing them. But was wondering if I can do without using csv’s.
As a note, all that string concatenation isn’t strictly necessary. PowerShell replaces variables with their values inside double quotes. Just makes reading the code a little easier.
The help says that -EmailAddresses accepts one object of the type ProxyAddressCollection. You’re providing a single, comma-delimited string as a single value within a hash table.
Notice the comma location in relation to the quotes: It’s OUTSIDE the quotes. So this example is appending two new values to the proper, and then passing the mailbox object to Set-Mailbox. That’s because it’s often easier to get the necessary collection object by just getting the mailbox.
This is closer to what you’re trying to do, except the hash table needs a key (either ‘Add’ or ‘Remove’), with the value being the e-mail address. I imagine this would also be legal:
Don, in this example you make an error: Set-Mailbox bsuneja -EmailAddresses @{Add=‘bharat.suneja@e14labs.com’;Add=‘poo@lovable.com’}
This leads to double hash key, the right oneliner is Set-Mailbox bsuneja -EmailAddresses @{Add=‘bharat.suneja@e14labs.com’,‘poo@lovable.com’}