-
Notifications
You must be signed in to change notification settings - Fork 216
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://-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 = ""
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_