-
Notifications
You must be signed in to change notification settings - Fork 6
/
install.ps1
38 lines (27 loc) · 1.41 KB
/
install.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
$ErrorActionPreference = 'Stop'
$arch = if ([Environment]::Is64BitOperatingSystem) { "amd64" } else { "386" }
$latestRelease = Invoke-RestMethod -Uri "https://api.github.com/repos/vulncheck-oss/cli/releases/latest"
$asset = $latestRelease.assets | Where-Object { $_.name -like "*windows_$arch.zip" } | Select-Object -First 1
if (-not $asset) {
Write-Error "No suitable release asset found for Windows $arch"
exit 1
}
$downloadUrl = $asset.browser_download_url
$zipPath = Join-Path $env:TEMP "vulncheck-cli.zip"
$extractPath = Join-Path $env:TEMP "vulncheck-cli"
Invoke-WebRequest -Uri $downloadUrl -OutFile $zipPath
Expand-Archive -Path $zipPath -DestinationPath $extractPath -Force
$exePath = Get-ChildItem -Path $extractPath -Filter "vulncheck.exe" -Recurse | Select-Object -First 1 -ExpandProperty FullName
if (-not $exePath) {
Write-Error "vulncheck.exe not found in the extracted files"
exit 1
}
$installPath = "$env:LOCALAPPDATA\Programs\vulncheck"
New-Item -ItemType Directory -Path $installPath -Force | Out-Null
Move-Item -Path $exePath -Destination $installPath -Force
$envPath = [Environment]::GetEnvironmentVariable("Path", "User")
if ($envPath -notlike "*$installPath*") {
[Environment]::SetEnvironmentVariable("Path", "$envPath;$installPath", "User")
}
Write-Host "Vulncheck CLI has been installed to $installPath"
Write-Host "You may need to restart your shell for the changes to take effect"