AD batch user account creation

I’m looking to create a script we can run in PowerShell to create 30-40 O365 exchange users at once, and also account for differing variables such as groups and OU. Thus far, I have the basic shell of being able to pull information from from Excel, but I’m not sure how to foolproof ensure that the script pulls the facing text and not the excel formula from each field, for places where we have truncation and concatenation.

Joshua,
Welcome to the forum. :wave:t4:

This forum is for scripting questions rather than script requests. We do not write customized and ready to use scripts or solutions on request.

We actually expect you to make an own attempt at the first place to get your task done or to solve your problem. If you have done so already please document here what exactly you have done and show your code. Then we probably might be able to help you step further.

Regardless of that - what you asked for is a very common task and has been asked a thousand times already and has been answered thousand times already. So no need to re-invent the wheel again. Use your prefered internet search engine to search for examples you can adapt to your particular needs.

I would also recommend to use CSV files instead of native Excel sheets since PowerShell is able to work with them out of the box. If you insist of using Excel sheets you may take a look at the great module from Doug Finke

There are different approaches thinkable. And it depends pretty much on the input files you get. The best way I would think of would be to get the data as raw as possible and do the actual needed logic with the PowerShell code. This way you’d reduce the chance to cointinue to work with the potentionally flawed input from others.

Here is a MS document for the account creation part.
Create Microsoft 365 user accounts with PowerShell - Microsoft 365 Enterprise | Microsoft Learn

If you are setup for hybrid identity and still have an on prem AD and azure AD connect configured, as an option you can create the accounts in your on prem AD, they will sync to AzureAD, then if you have a dynamic group setup for holding the M365 license, it is pretty much automated from there as far as “m365” accounts go.

Unless you have a need for or configured AzureAD Domain Services which can have OUs, there are no OUs in AzureAD
Overview of Azure Active Directory Domain Services | Microsoft Learn