Created
February 14, 2015 13:09
-
-
Save TheBigBear/bb99cab5fcf0a7d2fdd4 to your computer and use it in GitHub Desktop.
how to overcome this powershell quoting or invalid path issue?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
this code stumbles over the $Path being invalid , because some Uninstall entries contain characters that aren't valid in a file path, but are perfectly valid inside the regisry. | |
it gives me the error: | |
``` | |
Get-ItemProperty : Cannot retrieve the dynamic parameters for the cmdlet. The specified wildcard character pattern is | |
not valid: Bomgar Jump Client [help.ict-software.org-5478B883] | |
At C:\temp\Do-Uninstall.ps1:2 char:92 | |
+ ... l" | foreach { gp $_.PSPath } | ? { '$_' -match "Wget-1.11.4-1_is1" } | select U ... | |
+ ~~~~~~~~~~~~ | |
+ CategoryInfo : InvalidArgument: (:) [Get-ItemProperty], ParameterBindingException | |
+ FullyQualifiedErrorId : GetDynamicParametersException,Microsoft.PowerShell.Commands.GetItemPropertyCommand | |
``` | |
the Do-Uninstall.ps1 is: | |
``` | |
$uninstall32 = gci "HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall" | foreach { gp $_.PSPath } | ? { $_ -match "Wget-1.11.4-1_is1" } | select UninstallString | |
$uninstall64 = gci "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" | foreach { gp $_.PSPath } | ? { $_ -match "Wget-1.11.4-1_is1" } | select UninstallString | |
if ($uninstall64) { | |
$uninstall64 = $uninstall64.UninstallString -Replace "msiexec.exe","" -Replace "/I","" -Replace "/X","" | |
$uninstall64 = $uninstall64.Trim() | |
Write "Uninstalling(64)..." | |
write-verbose $uninstall64 | |
} | |
if ($uninstall32) { | |
$uninstall32 = $uninstall32.UninstallString -Replace "msiexec.exe","" -Replace "/I","" -Replace "/X","" | |
$uninstall32 = $uninstall32.Trim() | |
Write "Uninstalling(32)..." | |
write-verbose $uninstall32 | |
} | |
``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment