[CmdletBinding()] param( [Parameter(Mandatory = $true)] [string]$Device, [string]$AdbPath = "adb" ) $ErrorActionPreference = "Stop" if (Test-Path -LiteralPath $AdbPath -PathType Leaf) { $resolvedAdb = (Resolve-Path -LiteralPath $AdbPath).Path } else { $command = Get-Command -Name $AdbPath -CommandType Application -ErrorAction SilentlyContinue if ($null -eq $command) { throw "ADB was not found. Install Android platform-tools or pass -AdbPath with the full path to adb.exe." } $resolvedAdb = $command.Source } & $resolvedAdb connect $Device | Out-Null if ((& $resolvedAdb -s $Device get-state) -ne "device") { throw "The Shield is not connected and authorized." } & $resolvedAdb -s $Device shell "run-as com.dayline.tv sh -c 'rm -f files/base_url files/.base_url.new files/access_token files/.access_token.new files/allow_insecure_http files/.allow_insecure_http.new'" if ($LASTEXITCODE -ne 0) { throw "The local configuration could not be removed." } & $resolvedAdb -s $Device shell am force-stop com.dayline.tv & $resolvedAdb -s $Device shell am start -W -n com.dayline.tv/.MainActivity if ($LASTEXITCODE -ne 0) { throw "The organizer could not be relaunched." } Write-Host "Restored the hosted Site configuration on $Device. The legacy service_token was not changed."