fix: Improve folder path resolution and error handling in List-XlsFiles
This commit is contained in:
parent
5b593e7a2c
commit
c955fed489
@ -70,7 +70,14 @@ function List-XlsFiles {
|
||||
if (-not [string]::IsNullOrWhiteSpace($folderPath)) {
|
||||
$script:txtStatus.Text += "Searching in folder: $folderPath`n"
|
||||
# Get the folder ID first
|
||||
$folderItem = Invoke-MgGraphRequest -Method GET -Uri "https://graph.microsoft.com/v1.0/drives/$($drive.Id)/root:$($folderPath)"
|
||||
# Construct the correct URI for the folder
|
||||
$folderUri = "https://graph.microsoft.com/v1.0/drives/$($drive.Id)/root:$($folderPath)"
|
||||
$script:txtStatus.Text += "Folder URI: $folderUri`n"
|
||||
try {
|
||||
$folderItem = Invoke-MgGraphRequest -Method GET -Uri $folderUri -ErrorAction Stop
|
||||
} catch {
|
||||
throw "Folder not found: $($_.Exception.Message)"
|
||||
}
|
||||
$items = Get-MgDriveItemChild -DriveId $drive.Id -DriveItemId $folderItem.id
|
||||
} else {
|
||||
$script:txtStatus.Text += "Searching in root folder`n"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user