Sophos Central Server Protection Powershell install reboots before second installer finishes

I am able to install the first client installer without an issue, but the powershell script I have moves on because it detects that the first installer as finished and moves on in the script while the second scrambles to install in the background while other installers run. I can put in an artificial wait, but would prefer a better method of determining that the install has fully finished before moving onto the next installer.

  • Here is the line for the installer:

    Run-Command -program "$env:TEMP\SophosSetup.exe" -argumentString "--customertoken=""$sophosCustomerToken"" --mgmtserver=""$sophosMgmtServer"" --devicegroup=""$serverZone"" --proxyaddress=""$proxyAddress"" --products=""all"" --quiet"

    Here is the Run-Command function:

    function Run-Command() {

        param (

            [string]$program = $(throw "Please specify a program" ),

            [string]$argumentString = "",

            [switch]$waitForExit

        )

        $psi = new-object "Diagnostics.ProcessStartInfo"

        $psi.FileName = $program

        $psi.Arguments = $argumentString

        $psi.UseShellExecute = $false

        $proc = [Diagnostics.Process]::Start($psi)

        if ( $waitForExit ) {

            $proc.WaitForExit();

        }

    }

  • In reply to Bjorn Watland:

    Hi Bjorn,

    I've not done this myself, but if you don't want to add a WAIT to the script, could you look for the presence of a file/reg key that is written at the end of the 1st installer?

    Stephen

  • I do a start-process -filepath .\SophosSetup.exe -argumentlist "whatver your arguments are" -wait.  I can't think of a much cleaner way to do it.  I use that for OSD via SCCM and it works well.