Forum Discussion
Re: Microsoft Graph PowerShell SDK Module OneDrive Folder Permissions Assignment
How about this:
- Get the Drive ID for each user
$drive = Get-MgUserDrive -UserId $userUPN
- Get the Folder ID
Assuming you created myFolder in root/Documents:
$folder = Get-MgDriveItem -DriveId $drive.Id -ItemId 'root:/Documents/myFolder'
- Get the Group ID
$group = Get-MgGroup -Filter "displayName eq 'myGroup'"
- 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