# Select specific program using variable as an input

**URL:** <https://forums.powershell.org/t/select-specific-program-using-variable-as-an-input/17987>\
**Category:** PowerShell Help\
**Created:** [November 19, 2021, 6:45pm UTC](https://forums.powershell.org/t/select-specific-program-using-variable-as-an-input/17987 "2021-11-19T18:45:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rashkow](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/rashkow/32/1842_2.png) [@rashkow](https://forums.powershell.org/u/rashkow)\
**Post date:** [November 19, 2021, 6:45pm UTC](https://forums.powershell.org/t/select-specific-program-using-variable-as-an-input/17987/1 "2021-11-19T18:45:58Z")

</div>

Hi folks!  
I am having problem with this question.  
Get a specific program installed on your pc and then uninstall using powershell.  
I can find the program with this: Get-WMIObject -ComputerName “mindell” -Query “SELECT \* FROM Win32\_Product where Name like ‘%Teams%’”

But I need to use a variable in my fucntion to write any name as an input then use $app.Uninstall()  
But it is not working for me. Please can any one help me?

---

<div class="post-metadata">

**Author:** ![Jammer](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/jammer/32/1885_2.png) [@Jammer](https://forums.powershell.org/u/Jammer)\
**Post date:** [November 20, 2021, 1:36am UTC](https://forums.powershell.org/t/select-specific-program-using-variable-as-an-input/17987/2 "2021-11-20T01:36:05Z")

</div>

Hi,  
As mentioned to me Get-WMIObject is depricated and you should use Get-CimInstance.

Also DO NOT QUERY Win32\_Product

It will cause all products to run through the reinstall process as per:

> **[Windows Installer reconfigured all applications - Windows Server](https://docs.microsoft.com/en-us/troubleshoot/windows-server/admin-development/windows-installer-reconfigured-all-applications)**
>
> Fixes an error that indicates the Windows Installer reconfigured all installed applications.

If Configuration manager is used in your environment use: Win32reg\_AddRemovePrograms

Otherwise you should query the uninstall key in the registry or compile the mof on the system first (not a fand of compiling mofs but giving options: Google:

> **[Chapter 3: Looking Inside Configuration Manager](https://www.networkworld.com/article/2261034/chapter-3--looking-inside-configuration-manager.html?page=6)**
>
> Sams

Find Win32Reg\_AddRemovePrograms on page

You would probably want to find the right regisrty path then put that into a hashtable so the UninstallString value can be returned the way you want.

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:20pm UTC](https://forums.powershell.org/t/select-specific-program-using-variable-as-an-input/17987/3 "2024-05-16T20:20:25Z")

</div>


