Welcome to MSDN Blogs Sign in | Join | Help

Add/Remove users to a user role

Currently there is no cmdlet to add a user to a user role, however its very easy to do using a combination of the Get-UserRole cmdlet and a bit of the SDK.

$operatorsUserRole = Get-UserRole | where {$_.DisplayName -eq "Operations Manager Operators"}

$operatorsUserRole.Users.Add("contoso\AdOperators")

$operatorsUserRole.Update()

Removing users from a user role is very similar, just call Remove() rather than add.

$operatorsUserRole = Get-UserRole | where {$_.DisplayName -eq "Operations Manager Operators"}

$operatorsUserRole.Users.Remove("contoso\AdOperators")

$operatorsUserRole.Update()

 Dont forget to call the Update method on the user role object. Otherwise your changes will not be saved.

Published Monday, August 13, 2007 8:06 PM by Boris Yanushpolsky
Filed under:

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

Leave a Comment

(required) 
required 
(required) 
 
Page view tracker