Forum Discussion
JonGomes2295
Sep 12, 2023Copper Contributor
Installing from script
I am installing a bit of software using a Powershell script and deploying the script as a Win32App into the company portal. We need to supersede the script since the software is regularly updated...
rahuljindal
Sep 12, 2023Bronze Contributor
Can you post the script here and give more details on how you have set it up Intune?
- JonGomes2295Sep 12, 2023Copper Contributor
This is our Uninstall script.
As I said the uninstall script works fine if I run it through PowerShell through the desktop. Unfortunately just doesn't work through company portal.
It has to also delete 2 files
function LogWrite { param ( [Parameter(Mandatory = $true)] [string]$Msg, [string]$FilePath = $Logfile ) $date = (Get-Date -uFormat "[%H:%M:%S %d/%m/%Y]").ToString() $result = $date + " " + $Msg.ToString() Write-Output $result | Out-File -FilePath $FilePath -Append } #============================================================================== # GLOBAL VARIABLES #============================================================================== # Default registry paths $UninstallKey_x64 = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" $UninstallKey_x86 = "HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall" #LocalFolders $CC8_ProgramFiles = "C:\Program Files\Streets Heaver\Compucare8" #Logfile location $Logfile = "C:\Windows\Temp\UninstallSoftware-Compucare8_52.log" # CC8 registry paths $CC8_GUID = "{D69349D8-1635-4645-BF46-073582926E14}" $CC8_Version = "8.52.23116.1" # Remote Files $CC8_FileStore = ".\CC8-52_23116_1" $CC8_InstallFile = "setup.exe" $InstallArguments = "/S /v/qn" $OverrideXML = ".\Overrides\ClientOverrides.xml" $OverrideLicense = ".\Overrides\shacAuth.lic" #============================================================================== # CC8 UNINSTALLATION #============================================================================== # checks to see if the CC8 version is installed by looking for the uninstall registry key if (Test-Path $UninstallKey_x64\$CC8_GUID) { $CC8_DisplayVersion = (Get-ItemPropertyValue -Path $UninstallKey_x64\$CC8_GUID -Name "DisplayVersion") LogWrite "[INFORMATIONAL] Compucare $CC8_DisplayVersion detected, beginning uninstallation" # If CC8 is detected the uninstallation process begins $CC8_Uninstall = (start-process msiexec.exe -argumentlist "/x$CC8_GUID /qn" -Wait -Passthru).ExitCode if ($CC8_Uninstall -eq 0) { LogWrite "[SUCCESS] Compucare $CC8_DisplayVersion uninstallation completed with exit code: $CC8_Uninstall" # if CC8 is successfully removed then "C:\Program Files\Streets Heaver\Compucare8" and all of its contects are removed LogWrite "[SUCCESS] Clean up phase, removing $CC8_ProgramFiles" Remove-Item $CC8_ProgramFiles -recurse -force if (!(Test-Path $CC8_ProgramFiles)) { LogWrite "[SUCCESS] Program Files cleanup phase completed successfully" } else { LogWrite "[FAILURE] Program Files cleanup phase did not complete successfully" } } else { LogWrite "[FAILURE] Compucare $CC8_DisplayVersion uninstallation completed with exit code: $CC8_Uninstall" } }