Configuring Exchange mailboxes for a lot of users using powershell

Stefan Diedericks 125 Reputation points

I need to configure mailbox settings for 1000 users. I created a .csv file that has all there userprinciplenames ( When I do it one by one it all works, however the issue is when I try to reference a .csv file.

I would like to change their maxsendsize to 0mb and their (onlyacceptmessagesfrom@) should only be 3 people, everyone should not be able to send them emails. The file path is C:\Temp\users.csv

How do I properly reference the file that is all runs in a clean script?

Microsoft Exchange Online Management
Microsoft Exchange Online Management
Microsoft Exchange Online: A Microsoft email and calendaring hosted service.Management: The act or process of organizing, handling, directing or controlling something.
4,168 questions
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,041 questions
0 comments No comments
{count} votes

Accepted answer
  1. Vasil Michev 95,081 Reputation points MVP

    Something like this should work:

    Import-CSV C:\Temp\users.csv | % { Set-Mailbox $_.UserPrincipalName -MaxSendSize 0mb -AcceptMessagesOnlyFromSendersOrMembers @{add="user1","user2","user3"} -WhatIf}

    where I'm making the assumption that the CSV file has the UserPrincipalName column to reference each user, and the set of objects to configure message restrictions is predefined (the same) for all users.

    Make sure to run the sample with the -WhatIf switch, just in case.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful