Managing multiple user accounts can be a daunting task, particularly in large organizations. But thanks to Microsoft 365’s utilities such as the User Management interface and PowerShell, the process can be simplified and more efficient. One important aspect covered in the MS-100 ‘Microsoft 365 Identity and Services’ exam is how to perform bulk user management, including PowerShell.
Bulk User Operations in Microsoft 365 Admin Center
For basic bulk user operations such as creating, deleting, and editing multiple user accounts simultaneously, the Microsoft 365 admin center provides all the required functionalities.
The platform allows you to upload a .CSV (Comma Separated Values) file containing every user’s details that you want to modify. An example of the syntax is demonstrated below:
User Name,First Name,Last Name,Display Name,Job Title,Department,Office Number,Office Phone,Mobile Phone,Fax,Address,City,State or Province,ZIP or Postal Code,Country or Region
adam@yourdomain.com,Adam,Smith,Adam Smith,Project Manager,Management,123,123-456-7890,123-456-7891,123-456-7892,123 Main St.,Redmond,WA,12345,USA
This is an incredibly time-saving and efficient approach, particularly when you have to manage hundreds or thousands of users simultaneously. It’s essential that data be consistent when doing these bulk uploads, so be sure to thoroughly vet the file for errors before importing.
Using PowerShell for Bulk User Management
PowerShell takes the bulk user management in Microsoft 365 to a new level. This scripting language introduced by Microsoft allows administrators greater flexibility and control over managing user identities.
Installing PowerShell for Microsoft 365
To use PowerShell with Microsoft 365, you will need to install the Microsoft 365 module for PowerShell. You can do that with the following command in an elevated PowerShell window:
Install-Module MSOnline
Connecting to Microsoft 365
Once you’ve installed the required module, you will need to connect to your Microsoft 365 subscription. You can use the following command:
Connect-MsolService
Creating Multiple Users
For creating multiple users at once, the “Import-Csv” and “New-MsolUser” cmdlets can be used. The former cmdlet is used to read the data from a CSV file, while the latter is used to create new users.
You can prepare a CSV file containing all the required information and then use the following script to create users.
$users = Import-Csv -Path “UserList.csv”
foreach ($user in $users){
New-MsolUser -UserPrincipalName $user.UserPrincipalName -DisplayName $user.DisplayName -FirstName $user.FirstName -LastName $user.LastName -Password $user.Password
}
The script will iterate through each user in the CSV file and use the provided information to create a new user.
Deleting Multiple Users
Similarly, to delete multiple users, prepare a CSV file containing user principal names of the users, and then use the following script:
$users = Import-Csv -Path “UserList.csv”
foreach ($user in $users){
Remove-MsolUser -UserPrincipalName $user.UserPrincipalName -Force
}
This script will iterate through each user in the CSV file and delete the user in your Microsoft 365 subscription.
The capabilities to use PowerShell for bulk user management go far beyond these basic operations, it’s a very powerful tool for all Microsoft 365 administrators. In the MS-100 ‘Microsoft 365 Identity and Services’ exam, PowerShell, its commands, and how to effectively manage users in bulk constitutes a significant portion of the curriculum. The knowledge of user management helps administrators control and maintain the integrity of the organization’s user identities, ensuring a secured business environment.
Practice Test
True or False: PowerShell can be used to manage a large number of users in Microsoft
- True
- False
Answer: True.
Explanation: PowerShell is a scripting language that can be used to automate and manage user accounts in bulk in Microsoft
Which of the following are common tasks that you can perform with PowerShell for bulk user management in Microsoft 365? (Select all that apply)
- A. Deleting a user account
- B. Changing a user’s password
- C. Assigning a license to a user
- D. Changing a user’s avatar
Answer: A, B, C
Explanation: PowerShell can be used to automate various tasks such as deleting a user account, changing a user’s password, and assigning a license to a user. Changing a user’s avatar is not typically a task performed with PowerShell.
True or False: PowerShell cannot be used to create user accounts in Microsoft 365 in bulk.
- True
- False
Answer: False.
Explanation: PowerShell can be used to create multiple user accounts in Microsoft 365 at once, which is particularly useful for larger organizations.
Which of the following scripts can be used to list all the users in an organization in Microsoft 365 using PowerShell?
- A. Get-User
- B. Show-User
- C. List-User
- D. Find-User
Answer: A. Get-User
Explanation: The Get-User command in PowerShell is used to retrieve information about all the users in your Microsoft 365 organization.
PowerShell commands are case sensitive. True or false?
- True
- False
Answer: False.
Explanation: PowerShell is not case sensitive. ‘Get-User’ and ‘get-user’ are interpreted the same.
True or False: In order to use PowerShell for bulk user management in Microsoft 365, you need to be a Global Administrator.
- True
- False
Answer: True.
Explanation: To manage users in bulk using PowerShell, you need administrative permissions in Microsoft 365, typically a Global Administrator.
Which of the following PowerShell cmdlets would you use to Assign a License to a User?
- A. Set-MsolUserLicense
- B. Assign-MsolUserLicense
- C. Set-UserLicense
- D. License-User
Answer: A. Set-MsolUserLicense
Explanation: Set-MsolUserLicense is the correct cmdlet to assign a license to a user in Microsoft 365 using PowerShell.
True or False: You can use PowerShell to Reset a User’s Password in Microsoft
- True
- False
Answer: True.
Explanation: The Set-MsolUserPassword cmdlet in PowerShell can be used to reset a user’s password.
What PowerShell cmdlet is used to Remove a License from a User in Microsoft 365?
- A. Remove-MsolUserLicense
- B. Delete-UserLicense
- C. Unassign-UserLicense
- D. Revoke-MsolUserLicense
Answer: A. Remove-MsolUserLicense
Explanation: To remove a license from a user in Microsoft 365, the Remove-MsolUserLicense cmdlet is used.
True or False: PowerShell cannot be used to import users’ data from a CSV file.
- True
- False
Answer: False.
Explanation: PowerShell can be used to import users’ data into Microsoft 365 from a CSV file using the Import-Csv cmdlet.
Interview Questions
What is PowerShell in the context of Microsoft 365 user management?
PowerShell is a command-line shell created by Microsoft for system administration. It provides full access to COM and WMI, enabling system administrators to perform tasks on local and remote Windows systems.
How do you create a bulk of users using PowerShell in Microsoft 365?
You can create bulk users by using the ‘New-MsolUser’ cmdlet in PowerShell. You need a CSV file with user details, then use a ‘Foreach’ loop in PowerShell to go over each line and create a user.
What is the purpose of the ‘Set-MsolUser’ cmdlet?
The ‘Set-MsolUser’ cmdlet is used to update a user property in Microsoft 365. It can be used for updating user parameters like DisplayName, UserPrincipalName, etc.
Can you remove users in bulk using PowerShell?
Yes, users can be removed in bulk using PowerShell with the ‘Remove-MsolUser’ cmdlet. This can be used in a ‘Foreach’ loop to remove a set of users specified in a CSV or any iterable list.
How would you add users to Office 365 groups in bulk?
This can be accomplished using the ‘Add-UnifiedGroupLinks’ cmdlet in PowerShell. You need to specify the group and users to be added, typically done using a CSV file in a ‘Foreach’ loop.
Can the password of multiple users be reset using PowerShell in Microsoft 365?
Yes, you can reset passwords for multiple users in Microsoft 365 using PowerShell using the ‘Set-MsolUserPassword’ cmdlet, you just have to provide the UserPrincipalName and the new password.
How would you export the list of all users in Microsoft 365 using PowerShell?
You can export all users to a csv file using PowerShell by utilizing the ‘Get-MsolUser’ cmdlet and piping the output to ‘Export-Csv’.
What is the cmdlet to assign a license to a user in PowerShell?
The command to assign a license to a user in Microsoft 365 using PowerShell is ‘Set-MsolUserLicense’. You need to provide the UserPrincipalName and the license to be assigned.
How can you check if a user has a specific license using PowerShell?
You can use ‘Get-MsolUser’ cmdlet with the UserPrincipalName parameter and check the ‘Licenses’ property for each user.
Can you migrate mailboxes in bulk using PowerShell in Microsoft 365?
Yes, using the ‘New-MoveRequest’ cmdlet you can migrate mailboxes in bulk. This requires a source and target mailbox and possibly a CSV file if the migration is for a list of users.
What is the cmdlet to disable a user account in PowerShell?
To block a user account in Microsoft 365 using PowerShell, the ‘Set-MsolUser’ cmdlet is used with the -BlockCredential parameter.
How can you check the total number of user accounts in Microsoft 365 using PowerShell?
Use the ‘Get-MsolUser’ cmdlet piped into the ‘Measure-Object’ cmdlet. This provides a count of total users.
How would you assign an administrative role to a user using PowerShell in Microsoft 365?
The command to assign an administrative role in Microsoft 365 using PowerShell is ‘Add-MsolRoleMember’. You have to indicate the RoleObjectId and RoleMemberEmailAddress.
How to remove a license from a user using PowerShell in Microsoft 365?
The ‘Set-MsolUserLicense’ cmdlet can be used with the ‘-RemoveLicenses’ parameter to remove a license from a user.
How can you verify if a user belongs to a specific group using PowerShell in Microsoft 365?
You can use the ‘Get-MsolGroupMember’ cmdlet along with the name or unique ID of the group to obtain a list of all the members of the group. Then you can search the output for the specific user.