Fix USB drive detection logic for empty arrays

Replaces null comparison with count check to properly handle empty arrays. The previous condition would incorrectly pass when the array exists but contains no elements, potentially causing the function to proceed without a valid USB drive.
This commit is contained in:
rbalsleyMSFT
2025-11-24 17:41:36 -08:00
parent 417be73b23
commit 63ef35a005
+1 -1
View File
@@ -3494,7 +3494,7 @@ Function Get-USBDrive {
}
# Check if any USB drives were found
if ($null -eq $USBDrives) {
if ($USBDrives.Count -eq 0) {
WriteLog "No USB drive found. Exiting"
Write-Error "No USB drive found. Exiting"
exit 1