• subscribe
July 26, 2011 01:55 PM

Auditing 32-Bit and 64-Bit Applications with PowerShell

Script deals with the complexities so you don’t have to
Windows IT Pro
InstantDoc ID #136129
Downloads
136129_Get-InstalledApp.ps1.zip

Get-InstalledApp.ps1 is a PowerShell script that outputs information (e.g., display name, version, publisher) about the applications installed on one or more computers in a network. When I wrote this script back in 2009, I was using PowerShell 1.0 and only had to access 32-bit Windows OSs (see the web-exclusive article “What Applications Are Installed on the Computers in Your Network?”). Fast forward to 2011. I’m now using the 64-bit version of Windows 7, which has PowerShell 2.0 built-in. I wanted to use Get-InstalledApp.ps1 to output information about the applications installed on 64-bit and 32-bit Windows computers and instantly discovered that when I ran the script from the 64-bit version of PowerShell 2.0, it output only 64-bit applications. I had to start a 32-bit instance of PowerShell to find 32-bit applications. Needless to say, I was unhappy with this limitation.

I’ve now written a new version of Get-InstalledApp.ps1. It addresses this limitation and adds some new features, some of which should be particularly useful for people managing both 32-bit and 64-bit applications. The new version of the script requires PowerShell 2.0 and provides the following enhancements:

  • Comment-based Help information instead of a home-grown help function. If you put the script in a directory in your path, the command

    Get-Help Get-InstalledApp
    displays Help information for the script.

  • The script allows pipeline input in place of the -ComputerName parameter.
  • Application architecture detection (32-bit or 64-bit).

Using the Script

To download Get-InstalledApp.ps1, scroll to the top of this page and click the 136129.zip hotlink. The script's command-line syntax is as follows:

Get-InstalledApp

[-ComputerName <String[]>]

[-AppID <String>]

[-AppName <String>]

[-Publisher <String>]

[-Version <String>]

[-Architecture <String>]

[-MatchAll]

The -ComputerName parameter is optional. If you omit it, the script outputs information about the applications installed on the local computer. If you pipe input to the script, the script uses the piped input for the -ComputerName parameter. Because it’s the first positional parameter, you can omit the parameter’s name (-ComputerName) if you specify a computer name (or a list of computer names) as the script's first parameter.

The optional -AppID parameter lets you search for a particular application by its ID. The application ID is the application's registry subkey name, which is under the Uninstall key in the registry. This parameter is particularly useful for searching for applications installed with Windows Installer, as the application ID is the same as the application's product code globally unique identifier (GUID). You can use wildcards in the -AppID parameter's value. If the value contains curly braces ({ }), you need to enclose it in double quotes (" "); otherwise, PowerShell will think you’re specifying a hash table.

The optional -AppName, -Publisher, and -Version parameters behave the same way as in the earlier version of the script. These parameters let you search for applications by name, publisher, and version, respectively. All three parameters support wildcard matching and are case insensitive.

You can specify one of two strings—64-bit or 32-bit—for the optional -Architecture parameter, depending on whether you want to search for 64-bit or 32-bit applications. If you omit the -Architecture parameter, Get-InstalledApp.ps1 outputs information about both 64-bit and 32-bit applications.

When you’re looking for only one match (e.g., searching for an application by its ID), it’s unnecessary to continue the registry enumeration. So, the script returns only the first match by default to minimize network and registry access. When you need all the matches, you can use the -MatchAll parameter. If you include this parameter, the script lists the information about all matching applications instead of stopping after the first match. For example, the command

Get-InstalledApp -Publisher *Microsoft*

outputs information about the first application whose publisher contains the string Microsoft, whereas the command

Get-installedApp -Publisher *Microsoft*

-MatchAll

outputs information about all applications whose publisher contains the string Microsoft. (Although this command wraps here, you'd enter it all on one line in the PowerShell console. The same holds true for the other commands that wrap.)



ARTICLE TOOLS

Comments
  • Tim Bolton
    9 months ago
    Aug 03, 2011

    Bill, does this actually find all the applications?

    Referencing Greg's post.
    http://www.scriptlogic.com/smbit/article/top-tricks-in-inventorying-installed-applications-on-your-network
    Theres a problem, however, with the registry-based approach. Not every application deposits the correct (or, in many cases, any!) information to that location in the registry. In my case, while 7-Zip did indeed store its information in that location, I found no record of my installed copy of Camtasia, for example. Thats why getting a complete record of every application means also looking elsewhere. A second option is to see whats been stored in the computers WMI store. Many applications, when installed, add information about themselves to the WMI class called Win32_Product.

You must log on before posting a comment.

Are you a new visitor? Register Here