title: WMI - Invalid Class : Win32_InstalledWin32Program
body: <p>I have a script that loops through all the workstations from an Active Directory OU and pulls software data from each machine.</p>
  
  <p>I have found two classes that give me this data:</p>
  
  <pre><code>Win32_Product
  Win32_InstalledWin32Program
  </code></pre>
  
  <p><s>The latter is the more complete list, since by my understanding, <code>Win32_Product</code> only displays apps installed via windows installer, although the latter does not include an InstallDate property. Having an InstallDate is less crucial than having a complete list, so I've been unioning the output of my two <code>GWMI</code> commands and using <code>Sort-Object -Property Name -Unique</code> to give me close to what I'm looking for.</s>
  Edit: Have learned that querying Win32_Product triggers a consistency check for each software it queries, which may reinstall the program if it finds errors. Will be nixing Win32_Product entirely, and thanking whatever divine powers are out there, that I didn’t reinstall some critical production tool.
  <a href="https://support.microsoft.com/en-ca/help/974524/event-log-message-indicates-that-the-windows-installer-reconfigured-al" rel="nofollow noreferrer">https://support.microsoft.com/en-ca/help/974524/event-log-message-indicates-that-the-windows-installer-reconfigured-al</a></p>
  
  <p>For whatever reason, the <code>Win32_InstalledWin32Program</code>class is not available on some computers, and I get an <code>Get-WMIObject : Invalid Class</code> error. After checking with <code>Get-WMIObject</code> on several of the problem machines, I can confirm that the class I want is not available. <strong><em>Why might this be the case, and is there I way I can make it available to me?</em></strong> I can't find anything in the documentation about a dependency. All machines are running Windows 7, see screen capture below.</p>
  
  <pre><code>      $winProduct = GWMI Win32_Product -ComputerName $computer | Select-Object Name,Vendor,Version,InstallDate
        # vvv This fails on certain machines.
        $winPrograms = GWMI Win32_InstalledWin32Program -ComputerName $computer| Select-Object Name, Vendor, Version, InstallDate
        $winProduct + $winPrograms | Sort-Object -Property Name -Unique | export-csv -path $targetSWfile -notype
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/XFuRH.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XFuRH.png" alt="ProgramQuery Comparison"></a>
  <a href="https://i.stack.imgur.com/7Ed9y.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7Ed9y.png" alt="OSQuery Comparison"></a></p>