Shortly after querying the Win32_Product WMI class, I used the Get-EventLog cmdlet to query the application log for MSIInstaller events. The following image displays the commands and the output from the commands.īT, you may ask, “What about Marc Carter’s warning about using the Win32_Product WMI class? “ Well as seen in the results from querying the event log, it is a concern.
I then use the Get-WmiObject cmdlet ( gwmi is an alias) to query the Win32_Product WMI class, and I output the management objects to a table via the Format-Table ( ft is alias) cmdlet. In the image that follows, I import the HSGWMIModuleV6 module, use the Get-WMIKey function to retrieve the Key property of the Win32_Product WMI class. Gwmi win32_product | ft name, version, ident* In the code shown here, I use the Get-WmiObject cmdlet ( gwmi is an alias) to return product information, and then I pipe the management objects to the Format-Table ( ft is an alias) cmdlet for display. A table is a nice way to display the information. I only need to do this once, and I will have the three pieces of information. The easy way to get this information is to use the Get-WmiObject cmdlet to query for the information. The Key property for Win32_Product is a composite key comprised of IdentifyingNumber, Name, and Version. The commands and the output from the commands are shown here. In the following code, I first import my HSGWMImoduleV6 module, and then I use the Get-WMIKey function to return the key to the Win32_Product WMI class. I can use the Get-WMIKey function from my HSGWMImoduleV6 module. To connect to a specific instance, I must use the Key property of a WMI class. The problem is that the type accelerator returns a specific instance of a WMI class. It relies on using the type accelerator, instead of doing a generic WMI query. I immediately encouraged him to write a guest blog about this issue.īT, there is a way to use the Win32_Product WMI class in a more efficient manner. The Scripting Wife and I were in Texas for the Corpus Christi Windows PowerShell User Group meeting when Marc Carter told me about the problem with the MSI installer reconfiguring applications when the Win32_Product WMI class is queried. Microsoft Scripting Guy, Ed Wilson, is here. Is there any way to speed this thing up? I have to query over a thousand computers, and in our testing, this query takes nearly five minutes to complete-that would be three and a half days for only one query. I read the guest blog written by Marc Carter about problems using the Win32_Product WMI class, but it looks like I am going to be stuck using this anyway. Like I said, this is a really dumb application.
#Wmic uninstall update install
I tried looking in the registry, but the install key is empty…figures. The company has released a new version of this application, and I am trying to write a Windows PowerShell script to uninstall the old application-the problem is that I need to find the application first. Hey, Scripting Guy! We have a dumb application that we have to use at work.
#Wmic uninstall update how to
# Waiting until an existing Hotfix installation finish.Summary: Learn how to use Windows PowerShell to get software installation locations, and to uninstall software from remote computers.
PS C:\> Get-WmiObject -query "Select HotFixID from Win32_QuickFixengineering" | sort-object -Descending -Property HotFixID|% They were deinstalled in order from the highest to the lowest KB Number which increases speed of the remove process(Latest fix first).
#Wmic uninstall update update
Here is a “oneliner” to uninstall all Windows Update at once.