Add single or multiple Office 365 accounts via PowerShell

Adding single or multiple accounts in Microsoft Office 365 using PowerShell involves a command line script that effectively manages user accounts. Using PowerShell, we can add users in Microsoft 365 which will automate the task and make our work faster than adding one-by-one users. Also, the PowerShell command ensures consistency and accuracy of the data by saving our precious time compared to manual entry.

What is PowerShell

PowerShell is a command line interface used to write and run scripts to automate the tasks on the computers. Using PowerShell, you can perform complex tasks effectively. This is generally used to handle large groups of data or automate repetitive tasks on computers.

How to add a single account

1: Run Windows PowerShell as an Administrator

2: Import Required Module: Make sure you have imported the module and contains the necessary cmdlets to manage your Microsoft 365 users and services.

Install-Module  -Name MSOnline

Install-Module –Name AzureAD

3.Connect to MSOnline Service: Authenticate to the MSOnline service using your credentials.

$credential = Get-Credential

This command script is used to connect to the office365 admit account.

4.Once you’re logged into your Exchange Online mailbox, the next step is to establish a connection with the Msolservice. To do this, enter the following command:

Connect-MsolService -Credential $UserCredential

5.Run this command in the PowerShell to Add a New User:

New-MsolUser -UserPrincipalName [email protected] -DisplayName “User Display Name” -FirstName “User First Name” -LastName “User Last Name” -UsageLocation US -LicenseAssignment “yourdomain:ENTERPRISEPACK” -Password “StrongPassword123”

How to add Multiple Accounts

 If you’ve got a batch of new employees and want to create their accounts all at once, PowerShell is the best tool for the job!

1.Prepare a CSV File:

  •  Launch New Excel and open a new page.
  • Add these headers in columns: UserPrincipalName, DisplayName, FirstName, LastName, Usage Location, License Assignment, and Password.
  • Fill all the required details in the CSV file.

Excel File

 

Save this document for your computer with the file name User.csv.

2.Use a Command to Import the CSV File:

  • Run this command: $users = Import-Csv -Path “C:\PathToYourFile\users.csv” after replacing C:\PathToYourFile\users.csv with the path of your csv file.

3.Add All Users:

  • To create this account run this command.foreach ($user in $users){New-MsolUser -UserPrincipalName $user.UserPrincipalName -DisplayName $user.DisplayName -FirstName $user.FirstName -LastName $user.LastName -UsageLocation $user.UsageLocation -LicenseAssignment $user.LicenseAssignment -Password $user.Password }
  •  This command processes your CSV file and sets up an account for each listed individual. Relax and let PowerShell handle everything!

4.Verify the Accounts:

  • Run this command to check if the accounts were created or not:

Get-MsolUser

  • You’ll see a list of all users in Office 365.

Tips to Remember

  • Remember to check your details twice before submitting them so that you will stay away from errors.
  • To make your security level high use a strong password.
  • Allocate the proper license to ensure users can access necessary tools.
  • If you find any difficulties, run Get-Help in PowerShell to access more instructions.

Conclusion

Setting up accounts or adding users to Office 365 using PowerShell is straightforward and efficient. Just follow the commands, and you’ll have accounts ready in no time. Whether you’re creating an account for a single user or an entire team, PowerShell speeds up the process, making it quick and easy. Proper practice can make you proficient at managing Office 365 accounts effortlessly!

Also Visit: Guide to Add Single and Multiple Users in Office 365

By admin

Best OST to PST is a website that helps fix problems with OST files, like corruption or inaccessibility. The site also provides helpful blogs, tips, and solutions for all users, whether you’re a beginner or an expert.

Leave a Reply

Your email address will not be published. Required fields are marked *