Install Zabbix Massively Remotely
I'm trying to write a Powershell script to install Zabbix Agent remotely, but i'm stuck on the command for install using msi.
This is the script i'm using:
On remote system event viewer i got error 1603 on MSI Installer, but if i run this command line locally, agent works.
Anybody can help-me to solve this issue ?
Thanks.
I'm trying to write a Powershell script to install Zabbix Agent remotely, but i'm stuck on the command for install using msi.
This is the script i'm using:
Code:
$lines = Get-Content c:\tmp\zabbix.txt
$lines |
ForEach-Object{
$server = $_.Split(' ')[0]
$username = $_.Split(' ')[1]
$senha = $_.Split(' ')[2]
$pass = ConvertTo-SecureString -AsPlainText -Force -String $senha
$credential = New-Object System.Management.Automation.PSCredential("$($server)\$username",$pass)
$Session = New-PSSession -ComputerName "$server" -Credential $credential
#Command to create folder using variables.
Invoke-Command -Computername $server -Credential $credential -ScriptBlock {
New-Item -Path $USING:zabbix_dir -ItemType Directory }
#Copiar o instalador para o servidor
Copy-Item "$zabbix_dir\*" -Destination "$zabbix_dir" -ToSession $Session -Recurse
#Install Zabbix
Write-Host Installing Zabbix Agent
Invoke-Command -ComputerName $server -Credential $credential -ScriptBlock {
msiexec /I c:\tmp\zabbix\zabbix_agent-4.4.3-win-amd64-openssl.msi SERVER=fqdn.of.zabbix.server /qn
}
Write-Host Install End
Remove-PSSession $Session
}
Anybody can help-me to solve this issue ?
Thanks.
Comment