Skip to content

Instantly share code, notes, and snippets.

@nickadam
Created December 19, 2021 00:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nickadam/3bf6229cbb75d36b78ec19312cf6f4e2 to your computer and use it in GitHub Desktop.
Save nickadam/3bf6229cbb75d36b78ec19312cf6f4e2 to your computer and use it in GitHub Desktop.
Download and install salt-minion on windows
function Install-SaltClient(){
$FolderPath = "C:\ProgramData\SaltClient"
$FileName = "Salt-Minion-3004-2-Py3-AMD64.msi"
$Installer = $FolderPath + "\" + $FileName
$URL = "https://mywebserver.example.com/public/" + $FileName
$Hash = "11DE07BA38CA2B65B168237CA2485B1983A151528242C7BF81EC04A94660C0E8"
$SaltMaster = "mysaltmaster.example.com"
# Make Folder for tracking install
if(-not (Test-Path $FolderPath)){
mkdir $FolderPath
}
# Already attempted
if(Test-Path ($FolderPath + "\Attempted.txt")){
return
}
$HashCheck = $False
# We cannot check the file hash
if(Get-Command "Get-FileHash" -EA SilentlyContinue){
$HashCheck = $True
}
# Download installer
(New-Object System.Net.WebClient).DownloadFile($URL, $Installer)
# Download failed, bail
if(
$HashCheck -and
((Get-FileHash -Algorithm SHA256 $Installer).Hash -ne $Hash)
){
return
}
& msiexec /i $Installer /quiet /norestart MASTER=$SaltMaster
# touch a file so we don't run again
"" | Out-File -Encoding Default ($FolderPath + "\Attempted.txt")
}
Install-SaltClient
@nickadam
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment