Skip to content

Commit ce54aa1

Browse files
committed
added powershell section
1 parent f880215 commit ce54aa1

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

articles/active-directory/privileged-identity-management/pim-resource-roles-activate-your-roles.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,21 @@ Status code: 201
160160
"type": "Microsoft.Authorization/RoleAssignmentScheduleRequests"
161161
}
162162
````
163+
## Activate a role with PowerShell
164+
165+
There is also an option to activate Privileged Identity Management using PowerShell. You may find more details as documented in the article [PowerShell for Azure AD roles PIM](powershell-for-azure-ad-roles.md).
166+
167+
The following is a sample script for how to activate Azure resource roles using PowerShell.
168+
169+
```powershell
170+
$managementgroupID = "<management group ID" # Tenant Root Group
171+
$guid = (New-Guid)
172+
$startTime = Get-Date -Format o
173+
$userObjectID = "<user object ID"
174+
$RoleDefinitionID = "b24988ac-6180-42a0-ab88-20f7382dd24c" # Contributor
175+
$scope = "/providers/Microsoft.Management/managementGroups/$managementgroupID"
176+
New-AzRoleAssignmentScheduleRequest -Name $guid -Scope $scope -ExpirationDuration PT8H -ExpirationType AfterDuration -PrincipalId $userObjectID -RequestType SelfActivate -RoleDefinitionId /providersproviders/Microsoft.Management/managementGroups/$managementgroupID/providers/Microsoft.Authorization/roleDefinitions/$roledefinitionId -ScheduleInfoStartDateTime $startTime -Justification work
177+
```
163178

164179
## View the status of your requests
165180

0 commit comments

Comments
 (0)