forked from equinor/sdp-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create sharepoint-add-managed-identity.ps1
- Loading branch information
Showing
1 changed file
with
29 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# This script will grant the Managed Identity the correct permissions to the SharePoint site | ||
|
||
#The user running this has to be owner of the SharePoint sitem and be sharepoint admin | ||
|
||
# Add the correct 'Application (APP) ID' and 'displayName' for the Managed Identity | ||
$application = @{ | ||
id = "APP ID" | ||
displayName = "APP DISPLAY NAME" | ||
} | ||
|
||
# Add the correct role to grant the Managed Identity (read or write) | ||
$appRole = "write" | ||
|
||
# Add the correct SharePoint Online tenant URL and site name | ||
#$spoTenant = "miljodir.sharepoint.com" | ||
$spoSite = "SITE ID" | ||
|
||
# No need to change anything below | ||
#$spoSiteId = $spoTenant + ":/sites/" + $spoSite + ":" | ||
|
||
Import-Module Microsoft.Graph.Sites | ||
Connect-MgGraph -Scope Sites.FullControl.All | ||
|
||
#New-MgSitePermission -SiteId $spoSiteId -Roles $appRole -GrantedToIdentities @{ Application = $application } | ||
|
||
New-MgSitePermission -SiteId $spoSite -Roles $appRole -GrantedToIdentities @{ Application = $application } | ||
|
||
#To check the permissions run the following command | ||
#get-mgsitepermission -siteid $spoSite | format-list |