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!
You’re using the variable $UninstallString without defining it in advance.
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:
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.