Evening all
I have 2 questions about my script below.
The script installs symantec anti virus remotley.
-
How do i turn this into a job so it doesn’t hang my app when it’s running the function
-
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') {
$service.Start()
}
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"
DO
{
$status = (get-service -Name NetLogon -ComputerName $HostName).Status}
Until ($status -eq "Running")
$outputsepinstall.text = "$HostName is Online"}
}