Update-SCSMUserRole

Update-SCSMUserRole

Sets the UserRole property for a Service Manager user.

Syntax

Parameter Set: Default
Update-SCSMUserRole [-UserRole] <Role[]> [-PassThru] [-Confirm] [-WhatIf] [ <CommonParameters>]

Detailed Description

The Update-SCSMUserRole cmdlet sets the UserRole property for a Service Manager user.

Parameters

-PassThru

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

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-UserRole<Role[]>

Specifies the UserRole object to which to add the user.

Aliases

none

Required?

true

Position?

1

Default Value

none

Accept Pipeline Input?

true (ByValue)

Accept Wildcard Characters?

false

-Confirm

Prompts you for confirmation before running the cmdlet.

Required?

false

Position?

named

Default Value

false

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-WhatIf

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

Required?

false

Position?

named

Default Value

false

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

<CommonParameters>

This cmdlet supports the common parameters: -Verbose, -Debug, -ErrorAction, -ErrorVariable, -OutBuffer, and -OutVariable. For more information, see    about_CommonParameters (https://go.microsoft.com/fwlink/p/?LinkID=113216).

Inputs

The input type is the type of the objects that you can pipe to the cmdlet.

  • 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

The output type is the type of the objects that the cmdlet emits.

  • None.

    This cmdlet does not generate any output.

Examples

Example 1: Add a user to a user 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.

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 

Example 2: Remove a user from a role

This example removes a user from a user role. The first command displays administrators.

PS C:\> Get-SCSMUserRole -Name "Administrators"

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

Get-SCSMUser

Get-SCSMUserRole

New-SCSMUserRole

Remove-SCSMUserRole