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 }