Author Posts

April 19, 2016 at 12:33 pm

Evening all

I have 2 questions about my script below.

The script installs symantec anti virus remotley.

1. How do i turn this into a job so it doesn't hang my app when it's running the function

2. The Win 7 part works fine but for XP it does not install.. It copies the files over correctly but doesn't seem to run the msi .. I've checked event view and nothing there.

Any assistance would be appriciated.

function SEPInstall {

$HostName = $InputBoxHW.text;

if([System.Windows.Forms.MessageBox]::Show("This will install SEP 12 on $HostName and reboot. Continue?", "SEP 12 Install",[System.Windows.Forms.MessageBoxButtons]::OKCancel) -eq "OK")

sleep 2

$outputsepinstall.text = write "Copying required files to $HostName"
 sleep 5
 $service = Get-Service 'RemoteRegistry' -cn $HostName
 If ($service.Status -match 'Stopped') {
 If (!(Test-Path \\$HostName\c$\temp\AVInstall\)) {
 mkdir \\$HostName\c$\temp\AVInstall\
 $os_type64 = (Get-WmiObject -ComputerName $HostName -Class Win32_ComputerSystem).SystemType -match '(x64)'
if ($os_type64 -eq "True") {$files = Get-ChildItem "\\DFS-EMEA\Distribution\Ldn\InstallerPackages\IWSEP12RU564B0100\"}

 $os_type32 = (Get-WmiObject -ComputerName $HostName -Class Win32_ComputerSystem).SystemType -match '(x86)' 
if ($os_type32 -eq "True") {$files = Get-ChildItem "\\DFS-EMEA\Distribution\Ldn\InstallerPackages\IWSEP12RU532B0100\"}

 Foreach ($file in $files) {
 Copy-Item $file.fullname "\\$HostName\c$\temp\AVInstall\" -recurse
 $outputsepinstall.text = write "Installing SEP12 on $HostName"
 sleep 5
 if ($os_type64 -eq "True") {$process = Invoke-WMIMethod win32_process -name create -cn $HostName -ArgumentList 'msiexec /i "c:\temp\AVInstall\Sep64.msi" /qb'}

 if ($os_type32 -eq "True") {$process = Invoke-WMIMethod win32_process -name create -cn $HostName -ArgumentList 'msiexec /i "c:\temp\AVInstall\Sep.msi" /qb'}
 $id = $process.processid
 $a = ""
 do {
 $a = Get-Process -cn $HostName | Where{$_.ID -match "$ID"}
 While ($a -ne $null)

 del \\$HostName\c$\temp\AVInstall -force -recurse
 $outputsepinstall.text = write "Removing temp files from $HostName"
 sleep 10
 $outputsepinstall.text = write "Rebooting $HostName"
 sleep 5
 Restart-Computer -ComputerName $HostName -force

 sleep 40
 $outputsepinstall.text = write "Waiting for logon service to start"

$status = (get-service -Name NetLogon -ComputerName $HostName).Status}
Until ($status -eq "Running") 
$outputsepinstall.text = "$HostName is Online"}

April 20, 2016 at 3:03 am

Invoke-WmiMethod has a -AsJob parameter. But, does de MSI install work when you execute this line directly?

Invoke-WMIMethod win32_process -name create -cn $HostName -ArgumentList 'msiexec /i "c:\temp\AVInstall\Sep64.msi" /qb'

April 20, 2016 at 3:45 am

I just kicked it off and i can see the event view details on the install.

April 20, 2016 at 3:56 am

I've also figured out my the 32bit verion on XP isn't working.
It doesn't seem to be creating a processID.

Is there anyway i can force it to?

April 20, 2016 at 4:01 am

Are you getting any error messages in the eventlog? Or on the console? Try using -Verbose.

April 20, 2016 at 4:05 am

I've done some research and its returnvalue 3 (Insufficient Privilege)

No idea how to get round this

April 20, 2016 at 4:43 am

I found that

Invoke-WmiMethod -Path Win32_Product -Name Install -ComputerName "GBRPWMVDI023615" -ArgumentList @($true,$null,"\\GBRPWMVDI023615\c$\temp\AVInstall\Sep.msi")

Works for installing but how do i monitor that there isn't a processid property on win32_product