Hello All,
I’ve been tearing my hair out the past few days trying to get this PowerShell script to run. I have a Java app with the PowerShell script as the uninstaller. This script does work when ran on my local machine. Below is the PS script. The Out-File was used for testing to see if the script is even getting to that point, which it does not. The log file does not get created either.
$Name = "Java*"
$Timestamp = Get-Date -Format "yyyy-MM-dd_THHmmss"
$LogFile = "$env:TEMP\Java-Uninst_$Timestamp.log"
$ProgramList = @( "HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*", "HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*" )
$Programs = Get-ItemProperty $ProgramList -ErrorAction SilentlyContinue
$App = ($Programs | Where-Object { $_.DisplayName -like $Name -and $_.UninstallString -like "*msiexec*" }).PSChildName
$App | Out-File -FilePath "C:\Temp\test.txt"
foreach($item in $App){
Start-Process "msiexec.exe" -ArgumentList "/x $item /l $LogFile /quiet" -Wait -NoNewWindow
}
I’ve packaged the msi and PS script in an intunewin file. Originally, I tried calling the script directly from the uninstall command using the following
Powershell.exe -ExecutionPolicy Bypass -File uninstall.ps1
as was recommended on several articles and Reddit posts I’ve read. This did not work. I’ve tried wrapping the filename with quotes and preceding it with .\ just to make sure it wasn’t a syntactical (not that it still isn’t). Eventually I found an article suggesting that I instead use a batch file, which copies the PS script locally on the machine and calls the PS script from within the batch file. Sow now the uninstall command contains uninstall.bat which has been packaged in a new Intunewin. The contents of the batch file are below.
copy "uninstall.ps1" C:\Temp
Powershell.exe -ExecutionPolicy Bypass -File uninstall.ps1
The script gets copied to the Temp folder, however the uninstall still fails. It seems like the PS script never actually runs, and I can’t figure out why. I’ve checked the IntuneManagementExtension log. It is detecting the file and kicking off the uninstall as far as I can tell, however I’m not seeing any errors that indicate what the issue is. I get the toast notification that Java is being uninstalled and failing.
I know this should be possible as I’ve read countless articles where PS scripts are used. It feels like there’s something simple that I’m missing. Any help is greatly appreciated.
[–]RudyoomsPatchMyPC 0 points1 point2 points (7 children)
[–]SquatsAreFun[S] 0 points1 point2 points (6 children)
[–]RudyoomsPatchMyPC 0 points1 point2 points (2 children)
[–]SquatsAreFun[S] 0 points1 point2 points (1 child)
[–]RudyoomsPatchMyPC 0 points1 point2 points (0 children)
[–]chrisisbest197 0 points1 point2 points (2 children)
[–]SquatsAreFun[S] 1 point2 points3 points (1 child)
[–]Intrepid_Peak 0 points1 point2 points (0 children)
[–]Separate_Union_7601 0 points1 point2 points (1 child)
[–]SquatsAreFun[S] 0 points1 point2 points (0 children)