Forum Discussion
ShaneGibson
Sep 28, 2023Copper Contributor
Microsoft Graph PowerShell SDK Module OneDrive Folder Permissions Assignment
As an M365 Global Admin, I have been tasked with creating a new folder in other users OneDrive root folder (Documents) we can call that folder 'myFolder', then I need to assign a Microsoft Azure Secu...
Kidd_Ip
Jul 27, 2025MVP
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}})