Azure PIM Audit report on role activation using powershell
I have come across a PowerShell script that reports on Azure role activations, the script works quite well and somewhat provides the required information, however it is missing some role activations and i am not sure what need to be changed on the script to ensure that it captures all role activations.
I have noticed that the script doesn't get the full role assignment for all users, which could explain the reason why some of the activations are being missed. Is there a way to improve the script to get all the role assignments and the last activation date for a user for each assigned role.
The script can be found below.
$useWorkspace
$workspaceId
$exportFilePath
$historyToQueryInDays
# Get users that are PIM eligible
Connect-MgGraph
Write-Host
if
"@
}
}
# Get all eligible role assignments
$eligibleRoles
# Get accounts to reference
$users
$servicePrincipals
$groups
$processedEligibleRoles
foreach
}
# Export the result as a CSV then open it
$processedEligibleRoles
Invoke-Item