# Passlish installer for Windows. # Run in PowerShell: irm https://passlish.com/install.ps1 | iex # It downloads Passlish Import for this computer from passlish.com, checks it against the published # checksum, installs it for your user only (no admin password) and opens it. # # Device access (contracts/DEVICE-ACCESS.md), in PowerShell opened as administrator: # iex "& { $(irm https://passlish.com/install.ps1) } -Device" # installs the Passlish device service for the whole computer. It asks you to approve before anything # is installed, then for the pairing code shown in Passlish, Devices. param([switch]$Device) $ErrorActionPreference = 'Stop' $arch = if ($env:PROCESSOR_ARCHITECTURE -eq 'ARM64') { 'arm64' } else { 'amd64' } $base = 'https://passlish.com/download' function Test-Download($path, $name) { $sums = (Invoke-WebRequest -Uri "$base/SHA256SUMS.txt" -UseBasicParsing).Content $line = ($sums -split "`n") | Where-Object { $_.Trim().EndsWith(" $name") } | Select-Object -First 1 $want = if ($line) { ($line.Trim() -split '\s+')[0] } else { '' } $got = (Get-FileHash -Path $path -Algorithm SHA256).Hash.ToLower() return ($want -and $want -eq $got) } if ($Device) { $admin = ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator) if (-not $admin) { Write-Host 'Open PowerShell as administrator (right-click, Run as administrator) and run the line again.'; return } $dfile = "passlish-device-windows-$arch.exe" $dtmp = Join-Path $env:TEMP $dfile Write-Host 'Downloading the Passlish device service...' Invoke-WebRequest -Uri "$base/$dfile" -OutFile $dtmp -UseBasicParsing if (-not (Test-Download $dtmp $dfile)) { Write-Host 'The download did not match its checksum. Nothing was installed.'; return } Write-Host 'Checked.' $ddir = Join-Path $env:ProgramFiles 'Passlish' New-Item -ItemType Directory -Force -Path $ddir | Out-Null $dout = Join-Path $ddir 'passlish-device.exe' if (Test-Path $dout) { & sc.exe stop PasslishDevice | Out-Null Start-Sleep -Seconds 2 # Keep the earlier version instead of deleting it. Move-Item $dout (Join-Path $ddir ('passlish-device-previous-' + (Get-Date -Format 'yyyyMMddHHmmss') + '.exe')) } Move-Item $dtmp $dout Unblock-File $dout & $dout setup --installer $env:USERNAME return } $file = "passlish-import-windows-$arch.exe" $dir = Join-Path $env:LOCALAPPDATA 'Passlish' New-Item -ItemType Directory -Force -Path $dir | Out-Null $tmp = Join-Path $env:TEMP $file Write-Host 'Downloading Passlish Import...' Invoke-WebRequest -Uri "$base/$file" -OutFile $tmp -UseBasicParsing if (-not (Test-Download $tmp $file)) { Write-Host 'The download did not match its checksum. Nothing was installed.'; return } Write-Host 'Checked.' $out = Join-Path $dir 'passlish-import.exe' # Keep the earlier version instead of deleting it. if (Test-Path $out) { Move-Item $out (Join-Path $dir ('previous-' + (Get-Date -Format 'yyyyMMddHHmmss') + '.exe')) } Move-Item $tmp $out Unblock-File $out Write-Host "Installed in $dir. Opening Passlish Import..." Start-Process $out Write-Host 'Passlish opens in your browser. Unlock it and press Bring in.'