Forum Discussion

ShaneGibson's avatar
ShaneGibson
Copper Contributor
Sep 28, 2023
Solved

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...
  • Tristan999's avatar
    Oct 06, 2023

    It would be helpful if you posted some code snippets for the Graph request.

    I am not sure if you are stuck with Microsoft Graph PowerShell, but I was able to do what you needed to do with PnP PowerShell:

    $url = "<ONEDRIVEURL>"
    Connect-PnPOnline -Url $url -Interactive
    $oneDriveDefaultListName = "Documents"
    $folderToCreate = "myFolder"
    $securityGroupToAdd = "Group1"
    $permission = "Contribute"
    Add-PnPFolder -Name $folderToCreate -Folder $oneDriveDefaultListName
    Set-PnPFolderPermission -List $oneDriveDefaultListName -Identity "$oneDriveDefaultListName/$folderToCreate" -User $securityGroupToAdd -AddRole $permission

    If you are stuck with Graph API (and Azure Security Groups), maybe take a look at these links:

     

    Send an invite to access an item - Microsoft Graph v1.0 | Microsoft Learn


    https://learn.microsoft.com/en-us/graph/api/resources/driverecipient?view=graph-rest-1.0#properties

Resources