Skip to content

[ENHANCEMENT] - Grant-PnPAzureADAppSitePermission doesn't work with multi-geo #2801

@bnalley

Description

@bnalley

Reporting an Issue or Missing Feature

Grant-PnPAzureADAppSitePermission doesn't work with multi-geo. Non default geos produce an error and can't grant sites.selected permissions to sites outside default geo.

Expected behavior

Please describe what output you expect to see from the PnP PowerShell Cmdlets
Expect permission to be set with this result:
#Works with default GEO
commands
Grant-PnPAzureADAppSitePermission -AppId $appid -DisplayName $appname -Site $site -Permissions Write
PS C:\Scripts\AzureAppScripts> Grant-PnPAzureADAppSitePermission -AppId $appid -DisplayName $appname -Site $site -Permissions Write

Result
Id : aTowaS50fG1zLnNwLmV4dHwyOTcwMjJiYy0wOWNmLTRiZTQtYThlZi00ZWM4ZmM1MDhmNDBANDQ1M2UwNDAtNzRhOS00MGIzLTkwMDAtNTYwNjliNGFiMzA5
Roles : {write}
Apps : {BrittneyTest, 297022bc-09cf-4be4-a8ef-4ec8fc508f40}

Actual behavior

Please describe what you see instead. Please provide samples of output or screenshots.
Result:
Grant-PnPAzureADAppSitePermission : {"error":{"code":"itemNotFound","message":"Item not
found","innerError":{"date":"2023-02-10T13:33:20","request-id":"cab7bc77-2cf7-4656-acd8-70823f920c4f","client-request-id":"cab7bc77-2cf7-4656-acd8-70823f920c4f"}}}
At line:1 char:1

  • Grant-PnPAzureADAppSitePermission -AppId $appid -DisplayName $appname ...
  •   + CategoryInfo          : InvalidOperation: (:) [Grant-PnPAzureADAppSitePermission], PSInvalidOperationException
      + FullyQualifiedErrorId : InvalidOperation,PnP.PowerShell.Commands.Apps.GrantPnPAzureADAppSitePermission
    
    

Steps to reproduce behavior

Please include complete script or code samples in-line or linked from gists
#my graph api app
$appid = "297022bc-09cf-4be4-a8ef-4ec8fc508f40"
$appname = "BrittneyTest"
$site = "https://bcgdev01.sharepoint.com/sites/BNTest"
$site1 = "https://bcgdev01asp.sharepoint.com/sites/bntest"
$site2 = "https://bcgdev01eur.sharepoint.com/sites/BrittneyTest"

#tenant urls
$devtenant = "https://bcgdev01-admin.sharepoint.com/" #default geo
$devEmea = "https://bcgdev01eur-admin.sharepoint.com/" #asp geo
$devAsiaP = "https://bcgdev01asp-admin.sharepoint.com/" #eur geo

Connect-PnPOnline -Url $devAsiaP -Interactive
#Works with default GEO
Grant-PnPAzureADAppSitePermission -AppId $appid -DisplayName $appname -Site $site -Permissions Write
#Doesn't work with other GEOS in tenant
#ASP geo
Connect-PnPOnline -Url $devAsiaP -Interactive
Grant-PnPAzureADAppSitePermission -AppId $appid -DisplayName $appname -Site $site1 -Permissions Write
#EUR geo
Connect-PnPOnline -Url $devEmea-Interactive
Grant-PnPAzureADAppSitePermission -AppId $appid -DisplayName $appname -Site $site2 -Permissions Write
Result for ASP and EUR
Grant-PnPAzureADAppSitePermission : {"error":{"code":"itemNotFound","message":"Item not
found","innerError":{"date":"2023-02-10T13:33:20","request-id":"cab7bc77-2cf7-4656-acd8-70823f920c4f","client-request-id":"cab7bc77-2cf7-4656-acd8-70823f920c4f"}}}
At line:1 char:1

  • Grant-PnPAzureADAppSitePermission -AppId $appid -DisplayName $appname ...
  •   + CategoryInfo          : InvalidOperation: (:) [Grant-PnPAzureADAppSitePermission], PSInvalidOperationException
      + FullyQualifiedErrorId : InvalidOperation,PnP.PowerShell.Commands.Apps.GrantPnPAzureADAppSitePermission
    
    

What is the version of the Cmdlet module you are running? 1.12.0

(you can retrieve this by executing Get-Module -Name "PnP.PowerShell" -ListAvailable)

Which operating system/environment are you running PnP PowerShell on?

- [ ] Windows

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions