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.

Scenario:

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.

Solution:

  1. Connect to Exchange Online using Remote Powershell.
  2. Run the following command to create the user:
    New-MsolUser -UserPrincipalName [email protected] -DisplayName “CSG” -FirstName “CSG” -LastName “CSG”
  3. Once the user is created decide which role you want to assign to the user with the following command:
    Add-MsolRoleMember -RoleName “Company Administrator” –RoleMemberEmailAddress  [email protected]
  4. Set a password to the newly created user witht the following command:
    Set-MsolUserPassword -userPrincipalName [email protected] -NewPassword “Abcd1234” -ForceChangePassword $false

Below is a list of the roles that can be assigned to a user:

Creating a User in PowerShell Screenshot

For more information on creating a user and assigning roles in Powershell, check out the following articles:

Was this article helpful?
YesNo