Any version of Dell Command Update remove script

Hello. I am new to powershell and need to run a script that will remove Dell Command Update from multiple different machines with multiple different versions. I have written then script but am having a bit of difficulty as there are brackets in the uninstallstring. I need to pass the uninstall string minus the brackets to command prompt. Currently the script does not work, complains about the replace command. It is both late and I am tired…so any help would be great! thank you!

$DellCommandUpdate = Get-ItemProperty -Path 'HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*' | Select-Object DisplayName, DisplayVersion, UninstallString | Where-Object {$_.DisplayName -match "Dell Command | Update"}
if ($DellCommandUpdate){
$Uninstall = "$UninstallString -replace '{',' ','}',''"}
& cmd /c $Uninstall

#Uninstallstring = MsiExec.exe /X{4CD85DD3-A024-4409-A0F2-F70DE1E4A935}

James,
Welcome to the forum. :wave:t4:

You’re using the variable $UninstallString without defining it in advance. :wink:
The -replace operator works with regex. Curly braces have special meaning in regex. If you want to search for them literally you have to excape them … something like this:

'MsiExec.exe /X{4CD85DD3-A024-4409-A0F2-F70DE1E4A935}' -replace '\{|\}'

And BTW:

When you get error messages running you code you should share them completely as well along with your code (formatted as code as well, please). :wink:

Sorry for my post it was late and I was tired. Let me attempt to clear this up a bit. The Get -ItemProperty locates the Registry keys based on it finding the DisplayName being = Dell Command | Update. Which I defined in the beginning statement. The uninstall string is defined in the registry keys as MsiExec.exe /X{4CD85DD3-A024-4409-A0F2-F70DE1E4A935} the number between the brackets changes based on the version. So after the ($DellCommandUpdate) and before the start of the subcommand I need to pull that registry key out, strip out the brackets, so it can be shoved in the variable $Uninstall which I had defined.
Maybe the better question is the Regkey is found above so I need to define that Regkey minus the brackets as the $Uninstall variable. I hope that makes sense. I only listed what the found variable was for this as a reference to what was found. Sorry about that.

Also, great tip about providing the error message itself. I will do that in the future.