Granting access to all sites using SharePoint API in GCC High tenants
Learn about granting Movebot access to all SharePoint sites in GCC High tenants by using Microsoft PowerShell.
Migrating SharePoint sites in GCC High tenants requires providing Movebot access to the sites. This can be done by using PowerShell with an account that has appropriate permission levels.
1. Install PowerShell on your computer and connect to Microsoft Graph GCC High
# Install once (current user)
Install-Module Microsoft.Graph -Scope CurrentUser -Force
Import-Module Microsoft.Graph
# Connect to the GCC High cloud
Connect-MgGraph -Environment USGov `
-Scopes "Application.ReadWrite.All", "AppRoleAssignment.ReadWrite.All", "Directory.Read.All"
# (Optional) confirm cloud
(Get-MgContext).Environment
Identify your app & SharePoint resource
# Your Entra app's CLIENT ID
$appId = "<YOUR-APP-CLIENT-ID>"
# Your app's service principal
$sp = Get-MgServicePrincipal -Filter "appId eq '$appId'"
# SharePoint Online resource SP in M365
$spoSp = Get-MgServicePrincipal -Filter "appId eq '00000003-0000-0ff1-ce00-000000000000'"
Find the
Sites.FullControl.All
App role on SPO and assign it to your app
# Locate the Sites.FullControl.All (application) role
$spoRole = $spoSp.AppRoles |
Where-Object { $_.Value -eq "Sites.FullControl.All" -and $_.AllowedMemberTypes -contains "Application" }
# Grant that role to your app's service principal
New-MgServicePrincipalAppRoleAssignment `
-ServicePrincipalId $sp.Id `
-PrincipalId $sp.Id `
-ResourceId $spoSp.Id `
-AppRoleId $spoRole.Id
Verify the assignment
Get-MgServicePrincipalAppRoleAssignment -ServicePrincipalId $sp.Id |
Where-Object { $_.ResourceDisplayName -match "SharePoint" } |
Select-Object ResourceDisplayName, AppRoleId, PrincipalDisplayName
You should see an assignment referencing SharePoint with an AppRoleId matching $spoRole.Id
.
Last updated
Was this helpful?