You are here

Unattended scripted install of Windows agent

2 posts / 0 new
Last post
JohnC-C
JohnC-C's picture
Unattended scripted install of Windows agent

I'm trying to script the installation of the Opsview Agent on Windows servers with Powershell. I have this code:-

function Install-Opsview
{
$urlBase = "https://s3.amazonaws.com/opsview-agents/Windows/"

if( Get-Is64bit ) {
$fileName = "Opsview_Windows_Agent_x64.msi"
}
else {
$fileName = "Opsview_Windows_Agent_Win32.msi"
}

$tmpFile = "$env:tmp\$fileName"

Get-WebContent -Url $urlBase$fileName | Set-Content $tmpfile
$result = (Start-Process -FilePath "msiexec.exe" -ArgumentList @("/a", "$tmpFile") -Wait -PassThru).ExitCode

Remove-Item $tmpFile

}

This works, but the installer always shows a modal dialog at the end of the process which requires a button to be clicked for no good reason whatsoever. Passsing /q or /qn causes the installer to fail silently with no error code.

What's the correct way to achieve an unattended installation?

JohnC-C
JohnC-C's picture
Putting code here is rather

Putting code here is rather painful, so here's the working solution.

http://poshcode.com/paste/440/