-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.ps1
55 lines (45 loc) · 1.95 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# PowerShell script to install NetVentory
$ErrorActionPreference = "Stop"
Write-Host "Installing NetVentory..." -ForegroundColor Blue
# Create temp directory
$tempDir = Join-Path $env:TEMP "netventory_install"
New-Item -ItemType Directory -Force -Path $tempDir | Out-Null
# Download URL
$downloadUrl = "https://raw.githubusercontent.com/RamboRogers/netventory/master/bins/netventory.zip"
$zipPath = Join-Path $tempDir "netventory.zip"
try {
# Download the zip file
Write-Host "Downloading NetVentory..." -ForegroundColor Blue
Invoke-WebRequest -Uri $downloadUrl -OutFile $zipPath
# Extract the zip
Write-Host "Extracting files..." -ForegroundColor Blue
Expand-Archive -Path $zipPath -DestinationPath $tempDir -Force
# Find the exe
$exePath = Get-ChildItem -Path $tempDir -Filter "netventory-windows-amd64.exe" -Recurse | Select-Object -First 1
# Create destination directory in user's profile
$installDir = "$env:USERPROFILE\.netventory"
New-Item -ItemType Directory -Force -Path $installDir | Out-Null
# Copy the exe
Write-Host "Installing NetVentory to $installDir..." -ForegroundColor Blue
Copy-Item -Path $exePath.FullName -Destination "$installDir\netventory.exe" -Force
# Add to PATH if not already there
$userPath = [Environment]::GetEnvironmentVariable("Path", "User")
if ($userPath -notlike "*$installDir*") {
Write-Host "Adding NetVentory to PATH..." -ForegroundColor Blue
[Environment]::SetEnvironmentVariable(
"Path",
"$userPath;$installDir",
"User"
)
}
Write-Host "NetVentory installed successfully!" -ForegroundColor Green
Write-Host "Please restart your terminal, then run 'netventory -h' to see available options." -ForegroundColor Blue
}
catch {
Write-Host "Error installing NetVentory: $_" -ForegroundColor Red
exit 1
}
finally {
# Cleanup
Remove-Item -Path $tempDir -Recurse -Force -ErrorAction SilentlyContinue
}