https://github.com/PatchMyPCTeam/Community-Scripts/tree/main/Uninstall/Pre-Uninstall/Uninstall-Software
I can't add arguments when executing the PS1 from the cloud portal, so I'm trying to specify values like $DisplayName within the PS1 itself. I've set that value in the script in both locations where $DisplayName is set: under the 'AdditionalArguments' parameters, and under the Get-InstalledSoftware function.
Yet when I test run the PS1, it still prompts me to enter a value for DisplayName in the command line:
cmdlet Uninstall-Software.ps1 at command pipeline position 1
Supply values for the following parameters:
DisplayName:
Anyone know how I need to properly supply this value (or others) within the PS1?
Hello Red5sb,
As an example, I have used the Anywhere 365 integrator MSI version of the app to uninstall with Uninstall All Argument.
Please note that the Community Uninstall script queries the MSI silent uninstall string, and you can hardcode the silent uninstall string as suggested by the vendor; otherwise, the uninstallation may fail.
Please let me know if you have any questions or concerns.
param (
[Parameter(Mandatory = $false)]
[String]$DisplayName = "*Anywhere365 Integrator*",
[Parameter()]
[ValidateSet('Both', 'x86', 'x64')]
[String]$Architecture = 'Both',
[Parameter()]
[ValidateSet('HKLM', 'HKCU')]
[String[]]$HivesToSearch = 'HKLM',
[Parameter()]
[ValidateSet(1, 0)]
[Int]$WindowsInstaller,
[Parameter()]
[ValidateSet(1, 0)]
[Int]$SystemComponent,
[Parameter()]
[String]$VersionLessThan,
[Parameter()]
[String]$VersionEqualTo,
[Parameter()]
[String]$VersionGreaterThan,
[Parameter(ParameterSetName = 'EnforcedArguments')]
[String]$EnforcedArguments,
[Parameter(ParameterSetName = 'AdditionalArguments')]
[String]$AdditionalArguments,
[Parameter(ParameterSetName = 'AdditionalEXEorMSIArguments')]
[String]$AdditionalMSIArguments,
[Parameter(ParameterSetName = 'AdditionalEXEorMSIArguments')]
[String]$AdditionalEXEArguments,
[Parameter()]
[Switch]$UninstallAll = $true,
[Parameter()]
[Switch]$Force,
[Parameter()]
[String]$ProcessName,
[Parameter()]
[String[]]$RemovePath
)
Can the uninstall script be packaged as a Win32 application and run in system context with parameters being stated in the command line?
Hey Gwalker1,
The script above has been hardcoded to uninstall "Anywhere365 Integrator" as an example. Yes, you can use a community script to uninstall apps by modifying the parameters as needed.
It looks like the script isn't picking up the predefined value for $DisplayName. Try setting a default value within the script like $DisplayName = "YourValue" at the beginning. Also, ensure the parameter is not marked as [Parameter(Mandatory=$true)]. If you're running this via a cloud portal, check if the execution environment supports passing inline parameters. You might find more troubleshooting steps on the official documentation website (https://ikonicdev.com/).
Hey Vercel,
The script above is an example for uninstalling the Anywhere365 Integrator app. You can find the full script available on our GitHub repository here:
https://github.com/PatchMyPCTeam/Community-Scripts/blob/main/Uninstall/Pre-Uninstall/Uninstall-Software/Uninstall-Software.ps1
Let me know if you need any further assistance.