OK, so I looked at the log and it claimed to have ran the powershell script but nothing was done on the PC. I modified my script so that it doesn't require an argument and created a simple custom update to just run the uninstall script. No CustomUpdateEngine.log was created and nothing was uninstalled yet it reported successfully installed in Windows Update. Below is the powershell and then the xml for the update. Also, I added logging to the script and a log file was not created. How does wpp work with the powershell execution policy? Does the PC think it's running the script locally or off a network share? Or does it just ignore the execution policy? That could be the issue since I haven't ran any powershell scripts on the test PC before.
Param ([string]$iArch="32")
$log = "C:\Windows\Temp\jUI32.log"
$date = Get-Date
$ErrorActionPreference = "SilentlyContinue"
"******Import users script ran on " + $date + " by: "+$env:USERNAME+": " | Out-File $log -append
"---------------------------------------------------" | Out-File $log -append
$cArch = Get-WMIObject win32_processor -Property addresswidth | Select-Object -Property addresswidth
If ($cArch.addresswidth -eq "32")
{
$uninst = Get-ChildItem HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall | ForEach-Object {Get-ItemProperty $_.pspath} | Where {$_.DisplayName -like "Java ?* Update *"}
ForEach($i in $uninst)
{
#write-host $i.PSChildName
$n = $i.PSChildName
$cmd = "msiexec.exe"
$args = @("/x","$n","/quiet")
& $cmd $args
}
}
If ($cArch.addresswidth -eq "64")
{
$uninst = Get-ChildItem HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall | ForEach-Object {Get-ItemProperty $_.pspath} | Where {$_.DisplayName -like "Java ?* Update *"}
ForEach($i in $uninst)
{
#write-host $i.PSChildName
$n = $i.PSChildName
$cmd = "msiexec.exe"
$args = @("/x","$n","/quiet")
& $cmd $args | Out-File $log -append
$n+" - uninstalled" | Out-File $log -append
}
}
"---------------------------------------------------" | Out-File $log -append
<CustomUpdate>
<Action>
<ElementType>CustomUpdateElements.VariableElement</ElementType>
<Name>return</Name>
<Type>Int</Type>
<ID>2ebd075c-0b44-438d-b781-89fcd3f94689</ID>
</Action>
<Action>
<ElementType>CustomUpdateElements.ScriptElement</ElementType>
<ScriptType>Powershell</ScriptType>
<Filename>jUI32.ps1</Filename>
<Arguments></Arguments>
<KillProcess>False</KillProcess>
<TimeBeforeKilling>10</TimeBeforeKilling>
<Variable>2ebd075c-0b44-438d-b781-89fcd3f94689</Variable>
</Action>
</CustomUpdate>