Automated way to activate PIM roles.

Naga 20 Reputation points Microsoft External Staff
2026-04-20T16:21:31.26+00:00

Hi,
I am looking for an automated or script way to activate the PIM contributor or owner roles for a resource in azure instead of doing it via GUI.

Azure Automation
Azure Automation

An Azure service that is used to automate, configure, and install updates across hybrid environments.

0 comments No comments

Answer accepted by question author
Marcin Policht 112.8K Reputation points MVP Volunteer Moderator
2026-04-20T16:43:31.26+00:00

Refer to https://normansolutions.co.uk/automating-azure-pim-role-activation-with-powershell/

Script Overview

Authentication

Connects to Microsoft Graph with the necessary scopes for role management.

User Interface

Displays a simple Windows Form with checkboxes for roles like Global Reader, Exchange Administrator, and Intune Administrator.

Role Filtering

Fetches eligible roles for the current user and filters based on selections made in the form.

Activation Logic

Loops through selected roles and submits activation requests with a justification and expiration time.


If the above response helps answer your question, remember to "Accept Answer" so that others in the community facing similar issues can easily find the solution. Your contribution is highly appreciated.

hth

Marcin

Was this answer helpful?

0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.