need assistance with a quest AD cmdlets script / O365

We have been using this script to add x500 entries to on-premise exchange accounts, and it works great. [Script is from Subsun]

$csv = import-csv c:\scripts\userlist.csv
 foreach ($line in $csv) 
    $user=Get-Mailbox -Identity $line.Username
     Set-Mailbox -Identity $line.Username -EmailAddresses $user.EmailAddresses 

Open in new window

how can we run this against the office 365 accounts?

I've tried running and get this error [after connecting to the cloud via posh]

Property 'EmailAddresses' cannot be found on this object; make sure it exists and is settable.
At C:\Users\myaccount\Desktop\add-X500Address-toProxyAddresses.ps1:5 char:12
+      $user. <<<< EmailAddresses+="X500:"+$line.legacyExchangeDN
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : PropertyAssignmentException

Cannot bind argument to parameter 'Identity' because it is null.
    + CategoryInfo          : InvalidData: (:) [Set-Mailbox], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Set-Mailbox
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

It should work with exchange online accounts as well..

Try to set it for single user and see if it works.. You may refer the following article for instructions...

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
siber1Author Commented:
hi Subsun, when I try to run that manually on one account I get the error:

Propary 'emailAddresses' cannot be found on this object, make sure that it exists and is settable.

I also get that error when I run your script against the csv.

thx - S.
Hmm.. What you get for..
Get-Mailbox subsun | Select EmailAddresses

Open in new window

Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

siber1Author Commented:
that command works fine and lists the email addresses.

when I run your quest script against the input CSV here is the error:

Cannot process argument transformation on parameter 'Identity'. Cannot convert value "John Smith" to type "Microsoft
.Exchange.Configuration.Tasks.MailboxIdParameter". Error: "Cannot convert hashtable to an object of the following type:
 Microsoft.Exchange.Configuration.Tasks.MailboxIdParameter. Hashtable-to-Object conversion is not supported in restrict
ed language mode or a Data section."
    + CategoryInfo          : InvalidData: (:) [Set-Mailbox], ParameterBindin...mationException
    + FullyQualifiedErrorId : ParameterArgumentTransformationError,Set-Mailbox
Try changing line

Set-Mailbox -Identity $line.Username -EmailAddresses $user.EmailAddresses


Get-Mailbox $line.Username | Set-Mailbox -EmailAddresses $user.EmailAddresses
siber1Author Commented:
Hi Subsun,

slight correction, this is the code that I was using and it works for on premise, but not the cloud accounts:

Import-Csv Test.csv | % {
$user = Get-Mailbox $_.SMTP 
$user.emailAddresses += "X500:$($_.newsmtp)"
Set-Mailbox $user -emailAddresses $user.emailAddresses

Open in new window

input CSV column headers are: SMTP | newsmtp
siber1Author Commented:
thanks Subsun!
Sorry I was away, Is it working or are you still looking for assistance?
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.