Created
December 19, 2021 00:20
-
-
Save nickadam/3bf6229cbb75d36b78ec19312cf6f4e2 to your computer and use it in GitHub Desktop.
Download and install salt-minion on windows
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
More info, https://blog.opsecedu.com/find-log4j-with-saltproject-and-everything/