From 8f9df8e97d8c2be9d0ede8daebe0205322a83d19 Mon Sep 17 00:00:00 2001 From: "Bobby Abellana (aider)" Date: Wed, 19 Feb 2025 15:49:28 -0800 Subject: [PATCH] fix: correct folder retrieval by using DriveId and DriveItemId --- SharePointFunctions.ps1 | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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 {