Remove-AzRoleAssignment
拿掉指派給指定主體的角色指派給特定範圍中的特定角色。
Cmdlet 可能會根據輸入參數呼叫下列 Microsoft Graph API:
- GET /users/{id}
- GET /servicePrincipals/{id}
- GET /groups/{id}
- GET /directoryObjects/{id}
- POST /directoryObjects/getByIds
請注意,如果找不到角色指派的物件,或目前的帳戶沒有足夠的許可權可取得物件類型,此 Cmdlet 將會標示 ObjectType
為 Unknown
輸出中。
Syntax
Remove-AzRoleAssignment
-ObjectId <String>
[-Scope <String>]
-RoleDefinitionName <String>
[-PassThru]
[-SkipClientSideScopeValidation]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Remove-AzRoleAssignment
-ObjectId <String>
-ResourceGroupName <String>
-ResourceName <String>
-ResourceType <String>
[-ParentResource <String>]
-RoleDefinitionName <String>
[-PassThru]
[-SkipClientSideScopeValidation]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Remove-AzRoleAssignment
-ObjectId <String>
-ResourceGroupName <String>
-RoleDefinitionName <String>
[-PassThru]
[-SkipClientSideScopeValidation]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Remove-AzRoleAssignment
-ObjectId <String>
[-Scope <String>]
-RoleDefinitionName <String>
[-PassThru]
[-SkipClientSideScopeValidation]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Remove-AzRoleAssignment
-ObjectId <String>
[-Scope <String>]
-RoleDefinitionId <Guid>
[-PassThru]
[-SkipClientSideScopeValidation]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Remove-AzRoleAssignment
-SignInName <String>
-ResourceGroupName <String>
-ResourceName <String>
-ResourceType <String>
[-ParentResource <String>]
-RoleDefinitionName <String>
[-PassThru]
[-SkipClientSideScopeValidation]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Remove-AzRoleAssignment
-SignInName <String>
-ResourceGroupName <String>
-RoleDefinitionName <String>
[-PassThru]
[-SkipClientSideScopeValidation]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Remove-AzRoleAssignment
-SignInName <String>
[-Scope <String>]
-RoleDefinitionName <String>
[-PassThru]
[-SkipClientSideScopeValidation]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Remove-AzRoleAssignment
-ServicePrincipalName <String>
-ResourceGroupName <String>
-ResourceName <String>
-ResourceType <String>
[-ParentResource <String>]
-RoleDefinitionName <String>
[-PassThru]
[-SkipClientSideScopeValidation]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Remove-AzRoleAssignment
-ServicePrincipalName <String>
-ResourceGroupName <String>
-RoleDefinitionName <String>
[-PassThru]
[-SkipClientSideScopeValidation]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Remove-AzRoleAssignment
-ServicePrincipalName <String>
[-Scope <String>]
-RoleDefinitionName <String>
[-PassThru]
[-SkipClientSideScopeValidation]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Remove-AzRoleAssignment
[-PassThru]
[-InputObject] <PSRoleAssignment>
[-SkipClientSideScopeValidation]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Description
使用 Remove-AzRoleAssignment commandlet 撤銷指定範圍和指定角色上任何主體的存取權。 指派的物件,亦即必須指定主體。 主體可以是使用者(使用 SignInName 或 ObjectId 參數來識別使用者)、安全組(使用 ObjectId 參數來識別群組)或服務主體(使用 ServicePrincipalName 或 ObjectId 參數來識別 ServicePrincipal。 使用 RoleDefinitionName 參數指定主體指派給 MUST 的角色。 您可以指定指派的範圍,如果未指定,則預設為訂用帳戶範圍,亦即它會嘗試刪除訂用帳戶範圍中指定主體和角色的指派。 您可以使用下列其中一個參數來指定指派的範圍。 a. 範圍 - 這是從 /subscriptions/<subscriptionId> b 開始的完整範圍。 ResourceGroupName - 訂用帳戶下任何資源群組的名稱。 c. ResourceName、ResourceType、ResourceGroupName 和 (選擇性) ParentResource - 識別訂用帳戶下的特定資源。
範例
範例 1
Remove-AzRoleAssignment -ResourceGroupName rg1 -SignInName john.doe@contoso.com -RoleDefinitionName Reader
拿掉在 rg1 資源群組範圍中指派給讀取者角色的人員角色指派 john.doe@contoso.com 。
範例 2
Remove-AzRoleAssignment -ObjectId 36f81fc3-b00f-48cd-8218-3879f51ff39f -RoleDefinitionName Reader
拿掉 ObjectId 所識別群組主體的角色指派,並指派給讀取者角色。 默認為使用目前的訂用帳戶做為範圍,以尋找要刪除的指派。
範例 3
$roleassignment = Get-AzRoleAssignment |Select-Object -First 1 -Wait
Remove-AzRoleAssignment -InputObject $roleassignment
拿掉從 Get-AzRoleAssignment commandlet 擷取的第一個角色指派物件。
參數
-Confirm
執行 Cmdlet 之前先提示您確認。
Type: | SwitchParameter |
Aliases: | cf |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-DefaultProfile
用於與 azure 通訊的認證、帳戶、租用戶和訂用帳戶
Type: | IAzureContextContainer |
Aliases: | AzContext, AzureRmContext, AzureCredential |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-InputObject
角色指派物件。
Type: | PSRoleAssignment |
Position: | 0 |
Default value: | None |
Required: | True |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-ObjectId
使用者、群組或服務主體的 Microsoft Entra ObjectId。
Type: | String |
Aliases: | Id, PrincipalId |
Position: | Named |
Default value: | None |
Required: | True |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-ParentResource
階層中的父資源(使用 ResourceName 參數指定的資源),如果有的話。 必須與 ResourceGroupName、ResourceType 和 ResourceName 參數搭配使用,以識別資源的相對 URI 形式建構階層式範圍。
Type: | String |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-PassThru
如果指定,則顯示已刪除的角色指派
Type: | SwitchParameter |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-ResourceGroupName
指派角色的資源組名。 嘗試刪除指定資源群組範圍中的指派。 搭配 ResourceName、ResourceType 和 (選擇性)ParentResource 參數使用時,命令會以識別資源的相對 URI 形式建構階層式範圍。
Type: | String |
Position: | Named |
Default value: | None |
Required: | True |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-ResourceName
資源名稱。 例如 storageaccountprod。 必須與 ResourceGroupName、ResourceType 和 (選擇性)ParentResource 參數搭配使用,以相對 URI 的形式建構階層式範圍,以識別資源並刪除該範圍的工作分派。
Type: | String |
Position: | Named |
Default value: | None |
Required: | True |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-ResourceType
資源類型。 例如 Microsoft.Network/virtualNetworks。 必須與 ResourceGroupName、ResourceName 和 (選擇性)ParentResource 參數搭配使用,以相對 URI 的形式建構階層式範圍,以識別資源並刪除該資源範圍的工作分派。
Type: | String |
Position: | Named |
Default value: | None |
Required: | True |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-RoleDefinitionId
需要刪除指派的 RBAC 角色識別碼。
Type: | Guid |
Position: | Named |
Default value: | None |
Required: | True |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-RoleDefinitionName
需要刪除指派的 RBAC 角色名稱,例如讀者、參與者、虛擬網絡 管理員 istrator 等。
Type: | String |
Position: | Named |
Default value: | None |
Required: | True |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-Scope
要刪除的角色指派範圍。 以相對 URI 的格式。 例如“/subscriptions/9004a9fd-d58e-48dc-aeb2-4a4aec58606f/resourceGroups/TestRG”。 如果未指定,將會嘗試刪除訂用帳戶層級的角色。 如果指定,它應該以 “/subscriptions/{id}” 開頭。
Type: | String |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-ServicePrincipalName
Microsoft Entra 應用程式的 ServicePrincipalName
Type: | String |
Aliases: | SPN |
Position: | Named |
Default value: | None |
Required: | True |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-SignInName
用戶的電子郵件地址或用戶主體名稱。
Type: | String |
Aliases: | Email, UserPrincipalName |
Position: | Named |
Default value: | None |
Required: | True |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-SkipClientSideScopeValidation
如果指定,請略過客戶端範圍驗證。
Type: | SwitchParameter |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-WhatIf
Type: | SwitchParameter |
Aliases: | wi |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
輸入
輸出
備註
關鍵詞:azure, azurerm, arm, 資源, 管理, 管理員, 資源, 群組, 範本, 部署
相關連結
意見反應
https://aka.ms/ContentUserFeedback。
即將登場:在 2024 年,我們將逐步淘汰 GitHub 問題作為內容的意見反應機制,並將它取代為新的意見反應系統。 如需詳細資訊,請參閱:提交並檢視相關的意見反應