Share via


Update-SCSMUserRole

Sets the UserRole property for a Service Manager user.

Syntax

Default (Default)

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.

Parameter properties

Type:System.Management.Automation.SwitchParameter
Default value:False
Supports wildcards:False
DontShow:False
Aliases:cf

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-PassThru

Indicates that this cmdlet returns the user role that it updates. You can pass this object to other cmdlets.

Parameter properties

Type:System.Management.Automation.SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-UserRole

Specifies the UserRole object to which to add the user.

Parameter properties

Type:

Microsoft.EnterpriseManagement.ServiceManager.Sdk.UserRoles.Role[]

Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:0
Mandatory:True
Value from pipeline:True
Value from pipeline by property name:False
Value from remaining arguments:False

-WhatIf

Shows what would happen if the cmdlet runs. The cmdlet is not run.

Parameter properties

Type:System.Management.Automation.SwitchParameter
Default value:False
Supports wildcards:False
DontShow:False
Aliases:wi

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

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.