Office 365 Tech Tip: Creating a User in Powershell and Assigning a Role to a User
One of the great things about using Windows Powershell is the ability to assign a role to a user. When you’re organized, things generally run much smoother. Having the ability to create a users and assign roles to them ensures that users are held responsible, and accountable, for tasks assigned to them.
After reading this tech tip, you will be able to create a new user, assign a role and set a password in Windows Powershell.
An Administrator wants to create a new user using the Windows Azure Powershell module and wants to assign certain roles to the user. In the example below, I am creating a user in Powershell, assigning Global Administrative permissions and also setting a password.
2) Run the following command to create the user
Command: New-MsolUser -UserPrincipalName email@example.com -DisplayName “CSG” -FirstName “CSG” -LastName “CSG”
3) Once the user is created decide which role you want to assign to the user.
Command: Add-MsolRoleMember -RoleName “Company Administrator” –RoleMemberEmailAddress firstname.lastname@example.org
3) Set a password to the newly created user
Command: Set-MsolUserPassword -userPrincipalName email@example.com -NewPassword “Abcd1234” -ForceChangePassword $false
For more information on creating a user and assigning roles in Powershell, check out: