0

I'm new to StackOverflow so forgive me if I've done anything wrong.

Basically what I'm trying to do is use PowerShell or just the basic command line to search for a programs product code then use that code to uninstall that program. I have basically zero knowledge of how PowerShell works, so I'm not even sure if this is possible.

I found this code that searches for product code:

wmic product where "Name like '%(name)%'" get IdentifyingNumber

It returns something like this:

IdentifyingNumber {EC93F20F-825C-4828-8EB9-E4C93BD0A420}

Is there any way that that number can be pulled and put into this command?:

MsiExec.exe /qn /norestart /X{EC93F20F-825C-4828-8EB9-E4C93BD0A420}

Thank you for your help!

dpapadopoulos
  • 1,834
  • 5
  • 23
  • 34
OceanS
  • 1
  • Yes, it is possible. But I recommend for you to start with [learning the very basics of Powershell](https://mva.microsoft.com/en-us/training-courses/getting-started-with-powershell-3-0-jump-start-8276). It is far beyond the scope of SO to teach you how to write basic Powershell scripts. Regardless of that - there are literally at least hundreds of examples of such a task even here on SO. These kind of questions are asked 10 times a week - please search for it. Good luck. – Olaf Feb 22 '19 at 00:39
  • `msiexec /qn /norestart /X $((gcim Win32_Product -Filter "name like '%name%'").IdentifyingNumber)` – TessellatingHeckler Feb 22 '19 at 02:24
  • @TessellatingHeckler When I replace the "name" with the basic name of the program and run it in PowerShell, there is nothing returned and the program is still there. Am I doing something wrong? Thank you for helping! – OceanS Feb 22 '19 at 14:11
  • @Olaf Thank you for your help! I'm going to search more on here for it, and I'm definately trying to learn powershell, I just needed this quicker than I could possibly learn it. – OceanS Feb 22 '19 at 14:13
  • Does `gcim Win32_Product -Filter "name like '%name%'").IdentifyingNumber` return anything interesting? Does `gcim Win32_Product | Format-Table Name, IdentifyingNumber`? Find exacty what text it has for the name, and use that. (But NB. that Win32_Product is [not recommended](https://stackoverflow.com/q/25268491/478656)) – TessellatingHeckler Feb 22 '19 at 14:27

0 Answers0