Powershell to update Office365 user attributes

Hi,

I have located each mailbox that does not have archiving enabled.   Using the following.
Get-Mailbox |Where {$_.archivedatabase -eq $null}

For each of these mailboxes that do not currently have archiving, I need to:

- set msExchArchiveName to the name of the user
- set msExchRemoteRecipientType to 3

And then perform a directory sync.

Please help with this script.  I am very new to powershell.  

Thanks
AD1080Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
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.

Shreedhar EtteCommented:
Hi,

Do you have currently rich co-existences between both exchange organisations then please refer this article:
https://community.office365.com/en-us/f/158/t/4476
AD1080Author Commented:
Hi, we actually do not have an on premises server.    

I am currently getting this error below when trying to turn on archiving for most of our users.  

I found this article which appeared to address the same issue, and instructed me to set the values for msExchArchiveName to something and then set msExchRemoteRecipientType to 3.  

https://community.office365.com/en-us/f/158/t/61359

Here is the error I get in powershell when trying to enable archiving:

The following error occurred during validation in agent 'Windows LiveId Agent': 'Can't enable the archive for
'donotreply' because their primary mailbox is located on an on-premises server. To enable a cloud-based archive
mailbox for this user, you must use your on-premises Exchange admin center or Exchange Management Shell.'
    + CategoryInfo          : NotSpecified: (:) [Enable-Mailbox], ProvisioningValidationException
    + FullyQualifiedErrorId : [Server=SN1PR0301MB1581,RequestId=eef1bbd6-b12a-4d5b-877c-65d3975eaafb,TimeStamp=6/22/20
   15 11:44:41 PM] [FailureCategory=Cmdlet-ProvisioningValidationException] 8EF6FFA0,Microsoft.Exchange.Management.Re
  cipientTasks.EnableMailbox
    + PSComputerName        : outlook.office365.com
Shreedhar EtteCommented:
Hi,

As you don't have on premise exchange then only option is to manually modify the attributes on local active directly for each user.

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
AD1080Author Commented:
Hi,

Thanks for your time on this.
AD1080Author Commented:
Hi Shreedhar,

Do you mean in the Office 365 GUI admin center?

Thanks
Ariel
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
Powershell

From novice to tech pro — start learning today.