Update-SCSMUserRole
为 Service Manager 用户设置 UserRole 属性。
语法
Update-SCSMUserRole
[-UserRole] <Role[]>
[-PassThru]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
说明
Update-SCSMUserRole cmdlet 为Service Manager用户设置 UserRole 属性。
示例
示例 1:将用户添加到用户角色
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
第一个命令使用 Get-SCSMUserRole 获取名为 IncidentResolvers 的用户角色,然后将其存储在$Role变量中。
第二个命令使用 Get-SCSMUser cmdlet 获取用户,然后将该对象存储在$User变量中。
第三个命令将$User追加到 $Role 的 User 属性。
最终命令更新角色以匹配当前$Role值。
示例 2:从角色中删除用户
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
此示例从用户角色中删除用户。 第一个命令显示管理员。
参数
-Confirm
提示你在运行 cmdlet 之前进行确认。
Type: | System.Management.Automation.SwitchParameter |
Aliases: | cf |
Position: | Named |
Default value: | False |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-PassThru
指示此 cmdlet 返回更新的用户角色。 可以将此对象传递给其他 cmdlet。
Type: | System.Management.Automation.SwitchParameter |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-UserRole
指定要向其添加用户的 UserRole 对象。
Type: | Microsoft.EnterpriseManagement.ServiceManager.Sdk.UserRoles.Role[] |
Position: | 0 |
Default value: | None |
Required: | True |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-WhatIf
显示在此 cmdlet 运行的情况下将会发生什么。 此 cmdlet 未运行。
Type: | System.Management.Automation.SwitchParameter |
Aliases: | wi |
Position: | Named |
Default value: | False |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
输入
Microsoft.EnterpriseManagement.ServiceManager.Sdk.UserRoles.Role
可以通过管道将 UserRole 对象传递给 UserRole 参数。 若要获取用户角色,请使用 Get-SCSMUserRole cmdlet。
输出
None.
此 cmdlet 将不生成任何输出。