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 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.
Scenario:
An Administrator wants to create a user using the Windows Azure Powershell module and wants to assign certain roles to the user. In the example below, I am creating a new user, assigning Global Administrative permissions and also setting a password.
Solution:
1) Connect to Exchange Online using Remote Powershell.
2) Run the following command to create the user
Command: New-MsolUser -UserPrincipalName csg@ur-tenant.onmicrosoft.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 csg@ur-tenant.onmicrosoft.com
3) Set a password to the newly created user
Command: Set-MsolUserPassword -userPrincipalName csg@ur-tenant.onmicrosoft.com -NewPassword “Abcd1234″ -ForceChangePassword $false
Below is a list of the roles that
can be assigned to a user.
For more information on creating a user and assigning roles in Powershell, check out:
Connect
to Exchange Online Using Remote PowerShell
Assigning
Administrator Roles