Powershell Script Request. - Bulk Enable Archival (Office 365)

Isaias Perez
Isaias Perez used Ask the Experts™
on
Powershell Script Request. - Bulk Enable Archival (Office 365)

Im trying to setup a script that will do a fore each loop that will take CSV file that has a heading of UserPrincipalName of a list of 100s of F1 Licensed Users. i am trying to enable archival for all those users listed. I tried to get this started. I know that the command to enable archival is the following:

 Enable-Mailbox -Identity $usernames -Archive

So i started by trying to put the scrip together myself but i am kindve stuck. Not sure how to pass the object.


$usernames = Import- csv .... $_.UserPrincipalName

 foreach ($username in $usernames) {
   Enable-Mailbox -Identity $usernames -Archive
 }

Now I'm not 100% sure here that  -identity even takes the UPN, will have to research that. can anyone help?

https://docs.microsoft.com/en-us/microsoft-365/compliance/enable-archive-mailboxes
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
A lack of information provides a lack of a decent solution.
Commented:
Nearly

Drop the UPN's into a text file

$usernames = get-content c:\temp\UPN.txt

foreach ($username in $usernames) { Enable-Mailbox -Identity $username -Archive}
 

Open in new window



oh and it will take a UPN.

to break down your code


$usernames = Import- csv .... $_.UserPrincipalName

Open in new window


It's a single input, don't bother with a CSV

 foreach ($username in $usernames) {

Open in new window


Fine

   Enable-Mailbox -Identity $usernames -Archive
 }

Open in new window


$Usernames should be $username

Thanks
Alex
Top Expert 2016

Commented:
F1 does not support archiving to the best of my knowledge
Isaias PerezIT Operations Manager

Author

Commented:
Thank you very much Alex. This worked perfectly.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial