diff --git a/scripts/Common/Scripts/BrowserAutomation.ps1 b/scripts/Common/Scripts/BrowserAutomation.ps1 index 89b4b328..c26f953d 100644 --- a/scripts/Common/Scripts/BrowserAutomation.ps1 +++ b/scripts/Common/Scripts/BrowserAutomation.ps1 @@ -68,19 +68,19 @@ $null = New-Module { $downloadChecker = { $files = Get-ChildItem $dir; - if ((@($files)).Count -gt 0) { - foreach ($file in $files) { - try { - $stream = [System.IO.File]::Open($file.FullName, [System.IO.FileMode]::Open, [System.IO.FileAccess]::ReadWrite, [System.IO.FileShare]::None); + if ((@($files)).Count -eq 1) { + $file = $files[0]; - if ($stream) { - $stream.Close(); - } - } - catch { - return $true; + try { + $stream = [System.IO.File]::Open($file.FullName, [System.IO.FileMode]::Open, [System.IO.FileAccess]::ReadWrite, [System.IO.FileShare]::None); + + if ($stream) { + $stream.Close(); } } + catch { + return $true; + } return $false; } else {