Skip to content

Remove-MgBetaUserDriveRootPermission not working #3501

Description

Describe the bug

When I use Remove-MgUserDriveRootPermission works whitout errors but nothing happen in target drive.

When I use Remove-MgBetaUserDriveRootPermission the command never end.

Expected behavior

Remove permission for given drive

How to reproduce

Connect-PnPOnline -ClientId <pnp-cliend-id'> -Interactive -Url 'https://<tenant>-admin.sharepoint.com/'

$oneDrives = (Get-PnPTenantSite -IncludeOneDriveSites -Template 'SPSPERS#12') + (Get-PnPTenantSite -IncludeOneDriveSites -Template 'SPSPERS#10')

Disconnect-PnPOnline

Connect-MgGraph -Scopes 'Files.ReadWrite.All', 'Sites.ReadWrite.All', 'Directory.ReadWrite.All'

$admin = "<admin-id>"

foreach ( $od in $oneDrives ) {
    try {
        $drive = Get-MgUserDrive -UserId $od.Id -ErrorAction Stop | Where-Object { $_.Name -eq 'OneDrive' }

        $permId = (Get-MgUserDriveRootPermission -UserId $od.Owner -DriveId $drive.Id).GrantedToV2.User | { $_.Id -eq $admin }

        # this end with no error but nothing happen in target drive
        Remove-MgUserDriveRootPermission -UserId $od.Owern -DriveId $driveId -PermissionId $permId

        # this hangs the console
        Remove-MgBetaUserDriveRootPermission -UserId $od.Owern -DriveId $driveId -PermissionId $permId

}
    catch {
        Write-Host "No s'ha pogut esborrar l'admin a $($od.Url) o l'admin no existia" -ForegroundColor Red
    }
}  

SDK Version

2.34.0

Latest version known to work for scenario above?

No response

Known Workarounds

this works!

Connect-SPOService -Url 'https://-admin.sharepoint.com/'
PS C:\Users\pplanaguma> Set-SPOUser -Site 'https://-my.sharepoint.com/personal/' -LoginName -IsSiteCollectionAdmin $false

Debug output

Click to expand log ```
</details>


### Configuration

OS = Windows_NT (Windows 11, 25H2 Build 26200.7462)
PROCESSOR_ARCHITECTURE = AMD64
PSVersion = 7.5.4
PSEdition = Core

### Other information

_No response_

Activity

  1. lramosvea commented on Jan 26, 2026

    @lramosvea
    Contributor

    Pau Planagumà (@docjota) could you please provide the full debut output with all the calls to Microsoft Graph (i.e. dash debug parameter)?

  2. docjota commented on Feb 1, 2026

    @docjota
    Author

    This week I provide the full debug code, sorry for the delay

  3. microsoft-github-policy-service commented on Feb 13, 2026

    @microsoft-github-policy-service
    Contributor

    This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions