Add PSTools and win-acme installers

This commit is contained in:
Corbin 2024-09-13 17:54:36 -04:00
parent 06a799cc10
commit ec15a4e2d2
3 changed files with 81 additions and 1 deletions

View File

@ -29,5 +29,5 @@ Write-Host "Log saved at $($AgentInstallPath).log"
# Clean up
Write-Host "Removing package download from '$ArchivePath'"
Write-Host "Removing package download from '$AgentInstallPath'"
Remove-Item -Path $AgentInstallPath -Force

View File

@ -0,0 +1,40 @@
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls -bor [Net.SecurityProtocolType]::Tls11 -bor [Net.SecurityProtocolType]::Tls12
$PackagesPath = 'C:\Packages'
$DestinationPath = 'C:\Program Files\pstools'
$InstallerUrl = 'https://download.sysinternals.com/files/PSTools.zip'
$ArchivePath = Join-Path -Path $PackagesPath -ChildPath ($InstallerUrl | Select-String -Pattern "PSTools\.zip").Matches.Value
# Exit if the application is already installed
if (Test-Path $DestinationPath) { Write-Host 'PSTools is already installed.'; exit }
# Prep
# Create the $PackagesPath directory if it doesn't already exist
if (-not (Test-Path -PathType Container $PackagesPath)) { New-Item -ItemType Directory -Path $PackagesPath | Out-Null }
# Download
Write-Host "Downloading application..."
# Use Legacy WebClient for compatibility
(New-Object Net.WebClient).DownloadFile($InstallerUrl, $ArchivePath)
# Extract
Write-Host "Extracting application..."
Expand-Archive -Path $ArchivePath -DestinationPath $DestinationPath -Force
Write-Host "Application extracted to $DestinationPath"
# Install
Write-Host "Installing application..."
# Add the DestinationPath to Path system environment variable
[Environment]::SetEnvironmentVariable("Path", $env:Path + ";$DestinationPath\", [System.EnvironmentVariableTarget]::Machine)
# Clean up
Write-Host "Removing package download from '$ArchivePath'"
Remove-Item -Path $ArchivePath -Force

View File

@ -0,0 +1,40 @@
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls -bor [Net.SecurityProtocolType]::Tls11 -bor [Net.SecurityProtocolType]::Tls12
$PackagesPath = 'C:\Packages'
$DestinationPath = 'C:\Program Files\win-acme'
$InstallerUrl = 'https://github.com/win-acme/win-acme/releases/download/v2.2.9.1701/win-acme.v2.2.9.1701.x64.pluggable.zip'
$ArchivePath = Join-Path -Path $PackagesPath -ChildPath ($InstallerUrl | Select-String -Pattern "(win-acme\.v?(?:\d\.?)+\.x64\.pluggable\.zip)").Matches.Value
# Exit if the application is already installed
if (Test-Path $DestinationPath) { Write-Host 'win-acme is already installed.'; exit }
# Prep
# Create the $PackagesPath directory if it doesn't already exist
if (-not (Test-Path -PathType Container $PackagesPath)) { New-Item -ItemType Directory -Path $PackagesPath | Out-Null }
# Download
Write-Host "Downloading application..."
# Use Legacy WebClient for compatibility
(New-Object Net.WebClient).DownloadFile($InstallerUrl, $ArchivePath)
# Extract
Write-Host "Extracting application..."
Expand-Archive -Path $ArchivePath -DestinationPath $DestinationPath -Force
Write-Host "Application extracted to $DestinationPath"
# Install
Write-Host "Installing application..."
# Add the DestinationPath to Path system environment variable
[Environment]::SetEnvironmentVariable("Path", $env:Path + ";$DestinationPath\", [System.EnvironmentVariableTarget]::Machine)
# Clean up
Write-Host "Removing package download from '$ArchivePath'"
Remove-Item -Path $ArchivePath -Force