Hey guys,
The script below works fine. It copies the Java.exe to the specified create patch folder on the remote machine. The only thing I cant get to work is the removing it. I have the -force, but it still does not work. I cant figure it out. Please be patient with my coding. I am noob to powershell and I am just learning, so please forgive me for the format/ style. Any helpful tips it much appreciated. Thanks Powershell GURUS.
$ScriptBlock = {
param([String]$strComputer, $FileList, $scriptpath)
function InstallJava {
param([String]$strComputer, $objFile, $sysArch, $antiarch, $scriptpath)
write-host ""
write-host "Java install"
write-host ""
$JavaName = [string]$objFile.name
$JavaExt = $objFile.extension
$JavaFullName = $objFile.FullName
$JavaProc = ($JavaName.trimend(".exe"))
write-host $JavaProc
$JavaProc = [string]$JavaProc
If(!(Test-Path \\$StrComputer\c$\patch))
{
New-Item -type directory -path \\$StrComputer\c$\patch
}
Write-host “Patchs are being copied on $Computers”
copy-item $JavaFullName \\$strComputer\c$\PATCH\$JavaName -force
$install = (([WMICLASS]"\\$strComputer\ROOT\CIMV2:win32_process").Create("cmd /c c:\PATCH\$JavaName /s"))
start-sleep -Seconds 5
$javatest = get-process -cn $strComputer -name "$JavaProc"
while ($javatest -ne $null)
{
start-sleep -seconds 1
#write-host "waiting for java install to complete"
$javatest = get-process -cn $strComputer -name "$JavaProc"
}
#Java Auto Updater
copy-item -force “$scriptpath\wipejavaupdater.bat” “\$strComputer\c$\patch\wipejavaupdater.bat” -verbose
$install = (([WMICLASS]“\$strComputer\ROOT\CIMV2:win32_process”).Create(‘cmd /c start c:\wipejavaupdater.bat’)).processid
Remove-Item $JavaFullName \$strComputer\C$\Patch -force #Remove patches from remote system