param( [string]$msi ) $errorActionPreference="Stop" $drivePath="%SYSTEMDRIVE%" $regkey = 'HKLM:SOFTWARE\ManageEngine\OpManagerAgent' if(Test-Path $regkey){ $agentVersion =(Get-ItemProperty $regkey).AgentVersion } else{ $regkey = 'HKLM:SOFTWARE\WOW6432Node\ManageEngine\OpManagerAgent' if(Test-Path $regkey){ $agentVersion =(Get-ItemProperty $regkey).AgentVersion } } if( -not $agentVersion) { #Write-Output $PSScriptRoot [string]$msiFile = "$PSScriptRoot\$msi" cmd /c "msiexec.exe /i $msiFile ENABLESILENT=yes REBOOT=ReallySuppress /qn MSIRESTARTMANAGERCONTROL=Disable ALLUSERS=1 /lv $DrivePath\opmagentInstaller.log" } #Set-ExecutionPolicy RemoteSigned - cmd to allow PS scripts