Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Creating a User in Powershell and Assigning a Role to a User

$
0
0

One of the great things about using Windows Powershell is the ability to assign a role to a user. When you’re TechTips-by-MessageOps Creating a User in Powershell and Assigning a Role to a Userorganized, 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:Tech Tips Avatar Message Ops Creating a User in Powershell and Assigning a Role to a User
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.
Tech_Tip_MessageOps_Creating_a_User_in_PowerShell_

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

Connect to Exchange Online Using Remote PowerShell
Assigning Administrator Roles


Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>