From aed44fc07dcf53db7852478be1ce3211c5be8410 Mon Sep 17 00:00:00 2001 From: "Bobby Abellana (aider)" Date: Fri, 21 Feb 2025 09:50:07 -0800 Subject: [PATCH] fix: Check folder and child count before recursing in Get-XlsFilesRecursive --- SharePointFunctions.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SharePointFunctions.ps1 b/SharePointFunctions.ps1 index c282253..92b2da5 100644 --- a/SharePointFunctions.ps1 +++ b/SharePointFunctions.ps1 @@ -307,7 +307,7 @@ function Get-XlsFilesRecursive { $script:txtStatus.Text += "Checking item: $($item.Name)`n" # If it's a folder, recurse into it - if ($item.Folder) { + if ($item.Folder -and $item.Folder.ChildCount -ne $null) { # Check if it's a folder AND has children $script:txtStatus.Text += "Found folder: $($item.Name), recursing...`n" $allFiles += Get-XlsFilesRecursive -DriveId $DriveId -DriveItemId $item.Id }