Have you ever needed to create multiple 365 Groups/Security/Distribution at one time? This could be for a new department, new office, or even a new campaign that only certain people need access and email to. I won’t even go into the time it would take to do this in the GUI, but how would you add them scripting wise, as there are 4 types of Groups/Lists in 365. Do you only do one cmdlet at a time and hope someone doesn’t come back after you’ve already done some and they need to add another group with a cmdlet you’ve already used?
I have a nice simple one-liner to fix this issue.
Add-CT365Group -FilePath "C:\\Path\\to\\file.xlsx" -UserPrincialName "admin@domain.com" -Domain "domain.com"
That’s it.
Ok, to be fair, PowerShell wise that is all there is to it other than installing the 365AutomatedLab module from Github. After that only 3 steps needed, and well worth it. Here are the steps:
- Create a workbook in Excel, and have a sheet named “Groups”
- Add the Headers “DisplayName”, “PrimarySMTP”, “Description”, “Owner”, and “Type”
- DisplayName is self explanatory as this will be the Display name for the group
- PrimarySMTP is the email address without the @domain.com
- Description is self explanatory as this will be the description value for the group
- Owner is only a placeholder, but will be adding that soon
- Type will be the type of group it is – and will pull the corresponding cmdlet
- 365Group
- 365MailEnabledSecurity
- 365Distribution
- 365Security
- Add your Group information in the corresponding fields
After those are filled in, you can run the script from above pointing to where you saved that excel file, and all those groups you added to the Excel worksheet named “Groups” will be added (As long as you have the correct permissions)
It’s really that simple. I’m looking to expand the properties you can add into the groups, if there are any you’d rather see first, please let me know.
I hope you found this useful and it saves you time/headaches from having to more manually add them! As always if I can help out in anyway, please feel free to reach out!
Microsoft Documentation on Group Types
Leave a Reply