Skip to content

Instantly share code, notes, and snippets.

Created December 19, 2021 00:20
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
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 = "" + $FileName
$Hash = "11DE07BA38CA2B65B168237CA2485B1983A151528242C7BF81EC04A94660C0E8"
$SaltMaster = ""
# Make Folder for tracking install
if(-not (Test-Path $FolderPath)){
mkdir $FolderPath
# Already attempted
if(Test-Path ($FolderPath + "\Attempted.txt")){
$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
$HashCheck -and
((Get-FileHash -Algorithm SHA256 $Installer).Hash -ne $Hash)
& msiexec /i $Installer /quiet /norestart MASTER=$SaltMaster
# touch a file so we don't run again
"" | Out-File -Encoding Default ($FolderPath + "\Attempted.txt")
Copy link

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