@@ -59,10 +59,10 @@ Your custom role will show up in the list of available roles to assign.
59
59
60
60
### Connect to Azure
61
61
62
- To connect to Azure Active Directory , use the following command:
62
+ To connect to Microsoft Graph PowerShell , use the following command:
63
63
64
64
``` PowerShell
65
- Connect-AzureAD
65
+ Connect-MgGraph -Scopes "RoleManagement.Read.All"
66
66
```
67
67
68
68
### Create the custom role
@@ -81,10 +81,10 @@ $allowedResourceAction =
81
81
"microsoft.directory/applications/basic/update",
82
82
"microsoft.directory/applications/credentials/update"
83
83
)
84
- $rolePermissions = @{'allowedResourceActions' = $allowedResourceAction}
84
+ $rolePermissions = @(@{AllowedResourceActions = $allowedResourceAction})
85
85
86
86
# 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
88
88
```
89
89
90
90
### Assign the custom role using PowerShell
@@ -93,15 +93,15 @@ Assign the role using the below PowerShell script:
93
93
94
94
``` PowerShell
95
95
# 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'"
98
98
99
99
# 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 '"
101
101
$resourceScope = '/' + $appRegistration.objectId
102
102
103
103
# 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
105
105
```
106
106
107
107
## Create a role with the Microsoft Graph API
0 commit comments