Sorry if this is a duplicate, I posted a bit ago, I edited the post and then it appeared to have disapeared. I wanted to add something else to my post and cant find it now
I am really struggling with uninstalling apps that are EXE based uninstalls. The only method I have found that works is to put the actual path to the uninstall exe in the Path parameter.
Here is my current uninstall section
<pre class=“brush: powershell; gutter: true; first-line: 1; highlight: []; html-script: false”>
Function Uninstall-Application
{
<#
.SYNOPSIS
Perform all tasks necessary to remove the target application.
.DESCRIPTION
Perform all tasks necessary to remove the target application. The machine should
be left in a condition that would allow the wrapper to immediately attempt to
reinstall the application again.
.PARAMETER ContinueOnError
Default is $true; if $false exceptions and errors will be returned to caller.
.EXAMPLE
Uninstall-Application
.NOTES
.LINK
#>
[CmdletBinding()]
Param (
[Parameter(Mandatory = $false)]
[ValidateNotNullorEmpty()]
[boolean]$ContinueOnError = $true
)
Begin
{
## Get the name of this function and write header
[string]${CmdletName} = $PSCmdlet.MyInvocation.MyCommand.Name
Write-FunctionHeaderOrFooter -CmdletName ${CmdletName} -CmdletBoundParameters $PSBoundParameters -Header
}
Process
{
Try
{
Show-InstallationProgress -WindowLocation 'BottomRight' -StatusMessage "Searching for existing installs.<code>n</code>nPlease wait..."
Get-InstalledApplication -Name 'SoapUI' -RegEx | ForEach-Object {
# Early beta releases were tagged as coming from IBM; display name has been evolving so need to double verify
If ($_.Publisher -match 'SmartBear')
{
Show-InstallationProgress -WindowLocation 'BottomRight' -StatusMessage "Attempting to uninstall $($_.DisplayName).<code>n</code>nPlease wait..."
If ($_.UninstallString -match 'msiexec')
{
Show-InstallationProgress -WindowLocation 'BottomRight' -StatusMessage "Attempting to uninstall $($_.DisplayName) using the Windows Installer service.<code>n</code>nPlease wait.."
Remove-MSIApplications -Name $_.DisplayNameExact -Parameters "REBOOT=ReallySuppress /QN"
}
ElseIf ($_.UninstallString -match '^.+\.exe')
{
write-log -message "uninstall string = $_.UninstallString"
Show-InstallationProgress -WindowLocation 'BottomRight' -StatusMessage "Attempting to uninstall $($_.DisplayName) using the Windows Installer service.<code>n</code>nPlease wait.."
Execute-Process -path "<path to the EXE>" -Parameters "-q"
}
}
}
}
Catch
{
Write-Log -Message "Failed to uninstall application. `n$(Resolve-Error)" -Severity 3 -Source ${CmdletName}
If (-not $ContinueOnError)
{
Throw "Failed to uninstall application: $($_.Exception.Message)"
Show-InstallationProgress -WindowLocation 'BottomRight' -StatusMessage "Attempting to uninstall $($_.DisplayName) using the Windows Installer service.<code>n</code>nPlease wait.."
}
}
Finally
{
## If there is any resource cleanup that must be done regardless if an exception occurs put it here
}
}
End
{
Write-FunctionHeaderOrFooter -CmdletName ${CmdletName} -Footer
}
}
The Log shows that $_.uninstallstring = <![LOG[[Uninstallation] :: uninstall string = @{InstallDate=; Publisher=SmartBear Software; UninstallString=“C:\Program Files\SmartBear\SoapUI-5.4.0\uninstall.exe”; Is64BitApplication=True; InstallSource=; UninstallSubkey=5517-2803-0637-4585; ProductCode=; DisplayVersionExact=5.4.0; DisplayName=SoapUI 5.4.0 5.4.0; PublisherExact=SmartBear Software; DisplayNameExact=SoapUI 5.4.0 5.4.0; DisplayVersion=5.4.0; InstallLocation=C:\Program Files\SmartBear\SoapUI-5.4.0}.UninstallString]LOG]!><time=“13:09:32.540-300” date=“08-16-2018” component="" context=“GM-Win7-64\Administrator” type=“1” thread=“1724” file=“Deploy-Application.ps1”>
Shouldn’t the $_Uninstallstring just return the uninstall string? not all the properties of the key?
The log then shows an error of
Message : Exception calling “IsPathRooted” with “1” argument(s):
“Illegal characters in path.”
InnerException : System.ArgumentException: Illegal characters in path.
at System.IO.Path.CheckInvalidPathChars(String path,
Boolean checkAdditional)
at System.IO.Path.IsPathRooted(String path)
at CallSite.Target(Closure , CallSite , RuntimeType ,
Object )
I’m guessing this is because of the entire list of properties being returned?
I know enough Powershell to be dangerous, mainly to myself LOL, so any help would be greatly appreciated.
I am trying to uninstall all previous versions of SoapUI, and our company has more than 10 versions installed so I would really rather not have to check for each version and then call the “correct” uninstall exe path for each.