Update-SCSMUserRole
Sets the UserRole property for a Service Manager user.
Syntax
Update-SCSMUserRole
[-UserRole] <Role[]>
[-PassThru]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Description
The Update-SCSMUserRole cmdlet sets the UserRole property for a Service Manager user.
Examples
Example 1: Add a user to a user role
PS C:\>$Role = Get-SCSMUserRole -Name "IncidentResolvers"
PS C:\> $User = Get-SCSMUser -UserName "PattiFuller"
PS C:\> $Role.User += $User
PS C:\> Update-SCSMUserRole -Role $Role
The first command gets the user role named IncidentResolvers by using Get-SCSMUserRole, and then stores it in the $Role variable.
The second command gets a user by using the Get-SCSMUser cmdlet, and then stores that object in the $User variable.
The third command appends $User to the User property of $Role.
The final command updates the role to match the current value of $Role.
Example 2: Remove a user from a role
PS C:\>Get-SCSMUserRole -Name "Administrators"
WOODGROVE\Administrator
WOODGROVE\Domain Admins
The second command assigns the user role previously displayed to the $Role variable.
PS C:\>$Role = Get-SCSMUserRole -Name "Administrators"
The third command assigns the first user role to the **User** property of $Role. This command that property, removing all except the specified user.
PS C:\>$Role.User = $Role.Users[0]
The final command updates the role to match the current value of $Role.
PS C:\>Update-SCSMUserRole -Role $Role
This example removes a user from a user role. The first command displays administrators.
Parameters
-Confirm
Prompts you for confirmation before running the cmdlet.
Type: | System.Management.Automation.SwitchParameter |
Aliases: | cf |
Position: | Named |
Default value: | False |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-PassThru
Indicates that this cmdlet returns the user role that it updates. You can pass this object to other cmdlets.
Type: | System.Management.Automation.SwitchParameter |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-UserRole
Specifies the UserRole object to which to add the user.
Type: | Microsoft.EnterpriseManagement.ServiceManager.Sdk.UserRoles.Role[] |
Position: | 0 |
Default value: | None |
Required: | True |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-WhatIf
Shows what would happen if the cmdlet runs. The cmdlet is not run.
Type: | System.Management.Automation.SwitchParameter |
Aliases: | wi |
Position: | Named |
Default value: | False |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
Inputs
Microsoft.EnterpriseManagement.ServiceManager.Sdk.UserRoles.Role
You can pipe a UserRole object to the UserRole parameter. To obtain a user role, use the Get-SCSMUserRole cmdlet.
Outputs
None.
This cmdlet does not generate any output.