$ErrorActionPreference = 'Stop' $adbArguments = $args if ($adbArguments.Count -eq 0) { $adbArguments = @('devices', '-l') } $toolchain = & (Join-Path $PSScriptRoot 'env.ps1') if (-not (Test-Path -LiteralPath $toolchain.Adb -PathType Leaf)) { throw "Missing Android platform-tools: $($toolchain.Adb)" } Push-Location -LiteralPath $toolchain.Root try { & $toolchain.Adb @adbArguments $deviceExitCode = $LASTEXITCODE } finally { Pop-Location } exit $deviceExitCode