You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have an Azure automation runbook using a system-assigned Managed Identity.
When the runbook executes a Get-PnPGroup or Get-PnPGroupMember cmdlet, a "401 unauthorized" error is returned.
BTW, the same issue occurs with Get-PnPSiteCollectionAdmin.
Expected behavior
"Get-PnPGroup" returns a list of the SharePoint groups in the connected site collection.
"Get-PnPGroupMember -Group XXX" returns a list of the members in SharePoint group XXX.
Actual behavior
Response received:
{"odata.error":{"code":"-2147024891, System.UnauthorizedAccessException","message":{"lang":"en-US","value":"Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))"}}}
Steps to reproduce behavior
Create an Azure automation account.
Create a system-assigned managed identity.
Grant the following permissions to the managed identity:
dgwebb
changed the title
[BUG] Get-PnPGroup and Get-PnPGroupMember do not work with managed identity in Azure Automation runbook
[BUG] Get-PnPGroup and Get-PnPGroupMember in Azure Automation runbook with System-Assigned Managed Identity throw a Not Authorized error
Feb 27, 2025
I have an Azure automation runbook using a system-assigned Managed Identity.
When the runbook executes a Get-PnPGroup or Get-PnPGroupMember cmdlet, a "401 unauthorized" error is returned.
BTW, the same issue occurs with Get-PnPSiteCollectionAdmin.
Expected behavior
"Get-PnPGroup" returns a list of the SharePoint groups in the connected site collection.
"Get-PnPGroupMember -Group XXX" returns a list of the members in SharePoint group XXX.
Actual behavior
Response received:
{"odata.error":{"code":"-2147024891, System.UnauthorizedAccessException","message":{"lang":"en-US","value":"Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))"}}}
Steps to reproduce behavior
Sites.Read.All (SharePointOnline)
User.Read.All (Graph)
Group.Read.All (Graph)
GroupMember.Read.All (Graph)
$siteUrl = "... url here ..."
Connect-PnPOnline $siteUrl -ManagedIdentity
$groups = Get-PnPGroup # Error will occur on this statement
What is the version of the Cmdlet module you are running
2.12.0
Which operating system/environment are you running PnP PowerShell on?
The text was updated successfully, but these errors were encountered: