diff --git a/SharePointFunctions.ps1 b/SharePointFunctions.ps1 index c05bcb8..71c9bb8 100644 --- a/SharePointFunctions.ps1 +++ b/SharePointFunctions.ps1 @@ -138,9 +138,11 @@ function Get-FolderBrowser { throw "Library not found: $libraryName" } - # Get folders - $folders = Get-MgDriveRoot -DriveId $drive.Id | Get-MgDriveItemChild -DriveId $drive.Id - $folders = $folders | Where-Object { $_.Folder } + # Get root folder first + $root = Get-MgDriveRoot -DriveId $drive.Id + + # Get folders using the root item's ID + $folders = Get-MgDriveItemChild -DriveId $drive.Id -DriveItemId $root.Id | Where-Object { $_.Folder } # Create custom objects for the grid view $folderObjects = $folders | ForEach-Object {