Skip to content

Commit de5faed

Browse files
Merge pull request #248679 from bhaimicrosoft/update-manage-roles-portal
Update manage roles portal
2 parents 0201667 + 13ae7c1 commit de5faed

File tree

2 files changed

+36
-32
lines changed

2 files changed

+36
-32
lines changed

articles/active-directory/roles/custom-create.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@ Your custom role will show up in the list of available roles to assign.
5959

6060
### Connect to Azure
6161

62-
To connect to Azure Active Directory, use the following command:
62+
To connect to Microsoft Graph PowerShell, use the following command:
6363

6464
``` PowerShell
65-
Connect-AzureAD
65+
Connect-MgGraph -Scopes "RoleManagement.Read.All"
6666
```
6767

6868
### Create the custom role
@@ -81,10 +81,10 @@ $allowedResourceAction =
8181
"microsoft.directory/applications/basic/update",
8282
"microsoft.directory/applications/credentials/update"
8383
)
84-
$rolePermissions = @{'allowedResourceActions'= $allowedResourceAction}
84+
$rolePermissions = @(@{AllowedResourceActions= $allowedResourceAction})
8585
8686
# Create new custom admin role
87-
$customAdmin = New-AzureADMSRoleDefinition -RolePermissions $rolePermissions -DisplayName $displayName -Description $description -TemplateId $templateId -IsEnabled $true
87+
$customAdmin = New-MgRoleManagementDirectoryRoleDefinition -RolePermissions $rolePermissions -DisplayName $displayName -IsEnabled -Description $description -TemplateId $templateId
8888
```
8989

9090
### Assign the custom role using PowerShell
@@ -93,15 +93,15 @@ Assign the role using the below PowerShell script:
9393

9494
``` PowerShell
9595
# Get the user and role definition you want to link
96-
$user = Get-AzureADUser -Filter "userPrincipalName eq '[email protected]'"
97-
$roleDefinition = Get-AzureADMSRoleDefinition -Filter "displayName eq 'Application Support Administrator'"
96+
$user = Get-MgUser -Filter "userPrincipalName eq '[email protected]'"
97+
$roleDefinition = Get-MgRoleManagementDirectoryRoleDefinition -Filter "DisplayName eq 'Application Support Administrator'"
9898
9999
# Get app registration and construct resource scope for assignment.
100-
$appRegistration = Get-AzureADApplication -Filter "displayName eq 'f/128 Filter Photos'"
100+
$appRegistration = Get-MgApplication -Filter "Displayname eq 'POSTMAN'"
101101
$resourceScope = '/' + $appRegistration.objectId
102102
103103
# Create a scoped role assignment
104-
$roleAssignment = New-AzureADMSRoleAssignment -DirectoryScopeId $resourceScope -RoleDefinitionId $roleDefinition.Id -PrincipalId $user.objectId
104+
$roleAssignment = New-MgRoleManagementDirectoryRoleAssignment -DirectoryScopeId $resourcescope -RoleDefinitionId $roledefinition.Id -PrincipalId $user.Id
105105
```
106106

107107
## Create a role with the Microsoft Graph API

articles/active-directory/roles/manage-roles-portal.md

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -101,65 +101,69 @@ Follow these steps to assign Azure AD roles using PowerShell.
101101
1. Open a PowerShell window and use [Import-Module](/powershell/module/microsoft.powershell.core/import-module) to import the AzureADPreview module. For more information, see [Prerequisites to use PowerShell or Graph Explorer](prerequisites.md).
102102

103103
```powershell
104-
Import-Module -Name AzureADPreview -Force
104+
Import-Module -Name Microsoft.Graph.Identity.Governance -Force
105105
```
106106
107-
1. In a PowerShell window, use [Connect-AzureAD](/powershell/module/azuread/connect-azuread) to sign in to your tenant.
107+
1. In a PowerShell window, use [Connect-MgGraph](/powershell/microsoftgraph/authentication-commands?view=graph-powershell-1.0&preserve-view=true) to sign in to your tenant.
108108
109109
```powershell
110-
Connect-AzureAD
110+
Connect-MgGraph -Scopes "RoleManagement.ReadWrite.Directory"
111111
```
112112
113-
1. Use [Get-AzureADUser](/powershell/module/azuread/get-azureaduser) to get the user you want to assign a role to.
113+
1. Use [Get-MgUser](/powershell/module/microsoft.graph.users/get-mguser?view=graph-powershell-1.0&preserve-view=true) to get the user you want to assign a role to.
114114
115115
```powershell
116-
$user = Get-AzureADUser -Filter "userPrincipalName eq 'user@contoso.com'"
116+
$user = Get-MgUser -Filter "userPrincipalName eq 'johndoe@contoso.com'"
117117
```
118118
119119
### Assign a role
120120
121-
1. Use [Get-AzureADMSRoleDefinition](/powershell/module/azuread/get-azureadmsroledefinition) to get the role you want to assign.
121+
1. Use [Get-MgRoleManagementDirectoryRoleDefinition](/powershell/module/microsoft.graph.identity.governance/get-mgrolemanagementdirectoryroledefinition?view=graph-powershell-1.0&preserve-view=true) to get the role you want to assign.
122122
123123
```powershell
124-
$roleDefinition = Get-AzureADMSRoleDefinition -Filter "displayName eq 'Billing Administrator'"
124+
$roledefinition = Get-MgRoleManagementDirectoryRoleDefinition -Filter "DisplayName eq 'Billing Administrator'"
125125
```
126126
127-
1. Use [New-AzureADMSRoleAssignment](/powershell/module/azuread/new-azureadmsroleassignment) to assign the role.
127+
1. Use [New-MgRoleManagementDirectoryRoleAssignment](/powershell/module/microsoft.graph.identity.governance/new-mgrolemanagementdirectoryroleassignment?view=graph-powershell-1.0&preserve-view=true) to assign the role.
128128
129129
```powershell
130-
$roleAssignment = New-AzureADMSRoleAssignment -DirectoryScopeId '/' -RoleDefinitionId $roleDefinition.Id -PrincipalId $user.objectId
130+
$roleassignment = New-MgRoleManagementDirectoryRoleAssignment -DirectoryScopeId '/' -RoleDefinitionId $roledefinition.Id -PrincipalId $user.Id
131131
```
132132
133133
### Assign a role as eligible using PIM
134134
135135
If PIM is enabled, you have additional capabilities, such as making a user eligible for a role assignment or defining the start and end time for a role assignment. These capabilities use a different set of PowerShell commands. For more information about using PowerShell and PIM, see [PowerShell for Azure AD roles in Privileged Identity Management](../privileged-identity-management/powershell-for-azure-ad-roles.md).
136136
137137
138-
1. Use [Get-AzureADMSRoleDefinition](/powershell/module/azuread/get-azureadmsroledefinition) to get the role you want to assign.
138+
1. Use [Get-MgRoleManagementDirectoryRoleDefinition](/powershell/module/microsoft.graph.identity.governance/get-mgrolemanagementdirectoryroledefinition?view=graph-powershell-1.0&preserve-view=true) to get the role you want to assign.
139139
140140
```powershell
141-
$roleDefinition = Get-AzureADMSRoleDefinition -Filter "displayName eq 'Billing Administrator'"
141+
$roledefinition = Get-MgRoleManagementDirectoryRoleDefinition -Filter "DisplayName eq 'Billing Administrator'"
142142
```
143143
144-
1. Use [Get-AzureADMSPrivilegedResource](/powershell/module/azuread/get-azureadmsprivilegedresource) to get the privileged resource. In this case, your tenant.
144+
1. Use the following command to create a hash table to store all the necessary attributes required to assign the role to the user. The Principal ID will be the user id to which you want to assign the role. In this example, the assignment will be valid only for **10 hours**.
145145
146146
```powershell
147-
$aadTenant = Get-AzureADMSPrivilegedResource -ProviderId aadRoles
148-
```
149-
150-
1. Use [New-Object](/powershell/module/microsoft.powershell.utility/new-object) to create a new `AzureADMSPrivilegedSchedule` object to define the start and end time of the role assignment.
151-
152-
```powershell
153-
$schedule = New-Object Microsoft.Open.MSGraph.Model.AzureADMSPrivilegedSchedule
154-
$schedule.Type = "Once"
155-
$schedule.StartDateTime = (Get-Date).ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ss.fffZ")
156-
$schedule.EndDateTime = "2021-07-25T20:00:00.000Z"
147+
$params = @{
148+
"PrincipalId" = "053a6a7e-4a75-48bc-8324-d70f50ec0d91"
149+
"RoleDefinitionId" = "b0f54661-2d74-4c50-afa3-1ec803f12efe"
150+
"Justification" = "Add eligible assignment"
151+
"DirectoryScopeId" = "/"
152+
"Action" = "AdminAssign"
153+
"ScheduleInfo" = @{
154+
"StartDateTime" = Get-Date
155+
"Expiration" = @{
156+
"Type" = "AfterDuration"
157+
"Duration" = "PT10H"
158+
}
159+
}
160+
}
157161
```
158162
159-
1. Use [Open-AzureADMSPrivilegedRoleAssignmentRequest](/powershell/module/azuread/open-azureadmsprivilegedroleassignmentrequest) to assign the role as eligible.
163+
1. Use [New-MgRoleManagementDirectoryRoleEligibilityScheduleRequest](/powershell/module/microsoft.graph.identity.governance/new-mgrolemanagementdirectoryroleeligibilityschedulerequest?view=graph-powershell-1.0&preserve-view=true) to assign the role as eligible. Once the role has been assigned, it will reflect on the Azure portal under **Privileged Identity Management -> Azure AD Roles -> Assignments -> Eligible Assignments** section.
160164
161165
```powershell
162-
$roleAssignmentEligible = Open-AzureADMSPrivilegedRoleAssignmentRequest -ProviderId 'aadRoles' -ResourceId $aadTenant.Id -RoleDefinitionId $roleDefinition.Id -SubjectId $user.objectId -Type 'AdminAdd' -AssignmentState 'Eligible' -schedule $schedule -reason "Review billing info"
166+
New-MgRoleManagementDirectoryRoleEligibilityScheduleRequest -BodyParameter $params | Format-List Id, Status, Action, AppScopeId, DirectoryScopeId, RoleDefinitionId, IsValidationOnly, Justification, PrincipalId, CompletedDateTime, CreatedDateTime
163167
```
164168
165169
## Microsoft Graph API

0 commit comments

Comments
 (0)