Forum Discussion

Re: Microsoft Graph PowerShell SDK Module OneDrive Folder Permissions Assignment

How about this:

 

  1. Get the Drive ID for each user
$drive = Get-MgUserDrive -UserId $userUPN

 

  1. Get the Folder ID

Assuming you created myFolder in root/Documents:

$folder = Get-MgDriveItem -DriveId $drive.Id -ItemId 'root:/Documents/myFolder'

 

  1. Get the Group ID
$group = Get-MgGroup -Filter "displayName eq 'myGroup'"

 

  1. Assign Permissions

Use New-MgDriveItemPermission to grant access:

New-MgDriveItemPermission -DriveId $drive.Id `
    -DriveItemId $folder.Id `
    -Roles @("write") `
    -GrantedToIdentities @(@{Group=@{Id=$group.Id}})

 

No RepliesBe the first to reply

Resources