# Installs vpsm, the VPS Minute command-line tool, on Windows (PowerShell 5.1 or later): # irm https://panel.vps-minute.com/cli/install.ps1 | iex # Options (environment): $env:VPSM_VERSION = '1.0.0' (default: latest), $env:VPSM_INSTALL_DIR (default: # %LOCALAPPDATA%\Programs\vpsm, added to your user PATH). The archive is checked against SHA256SUMS. $ErrorActionPreference = 'Stop' $ProgressPreference = 'SilentlyContinue' [Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12 $base = if ($env:VPSM_DOWNLOAD) { $env:VPSM_DOWNLOAD } else { 'https://panel.vps-minute.com/cli' } $version = $env:VPSM_VERSION if (-not $version) { $version = (Invoke-RestMethod -UseBasicParsing "$base/latest").version } $arch = if ($env:PROCESSOR_ARCHITECTURE -eq 'ARM64' -or $env:PROCESSOR_ARCHITEW6432 -eq 'ARM64') { 'arm64' } else { 'amd64' } $file = "vpsm_${version}_windows_${arch}.zip" $tmp = Join-Path ([IO.Path]::GetTempPath()) ('vpsm-' + [guid]::NewGuid()) New-Item -ItemType Directory -Path $tmp | Out-Null try { Invoke-WebRequest -UseBasicParsing "$base/download/$version/$file" -OutFile (Join-Path $tmp $file) Invoke-WebRequest -UseBasicParsing "$base/download/$version/SHA256SUMS" -OutFile (Join-Path $tmp 'SHA256SUMS') $expected = '' foreach ($line in Get-Content (Join-Path $tmp 'SHA256SUMS')) { $parts = $line -split '\s+' if ($parts.Count -ge 2 -and $parts[1] -eq $file) { $expected = $parts[0] } } $actual = (Get-FileHash (Join-Path $tmp $file) -Algorithm SHA256).Hash.ToLower() if (-not $expected -or $expected -ne $actual) { throw "checksum mismatch for ${file}: nothing was installed" } Expand-Archive -Path (Join-Path $tmp $file) -DestinationPath $tmp -Force $dir = if ($env:VPSM_INSTALL_DIR) { $env:VPSM_INSTALL_DIR } else { Join-Path $env:LOCALAPPDATA 'Programs\vpsm' } New-Item -ItemType Directory -Force -Path $dir | Out-Null Copy-Item (Join-Path $tmp 'vpsm.exe') (Join-Path $dir 'vpsm.exe') -Force $userPath = [Environment]::GetEnvironmentVariable('Path', 'User') if (-not (($userPath -split ';') -contains $dir)) { $newPath = if ($userPath) { "$userPath;$dir" } else { $dir } [Environment]::SetEnvironmentVariable('Path', $newPath, 'User') $env:Path = "$env:Path;$dir" Write-Host "Added $dir to your PATH (new terminals see it)." } Write-Host "vpsm $version installed: $dir\vpsm.exe" Write-Host 'Next step: vpsm login (with an API key from your client area, Settings > Security > API keys)' } finally { Remove-Item -Recurse -Force $tmp -ErrorAction SilentlyContinue }