I was recently at a customer who needed to  get a report of software that was running on each computer. Since they did not have (or at least not fully deployed) a solution that could do that for them (e.g. System Center Configuration Manager), I  proposed to write a PowerShell script which would remotely check a computer using WMI.

Usage

The script accepts a single parameter to indicate the computer you want to get a list of installed applications from:

Get-InstalledApplications –Computer <computername>

The output can be formatted in different ways and even be exported to a file or printed on screen:

Get-InstalledApplications –Computer <computername> | Out-File <file>
or
Get-InstalledApplications -Computer <computername> | Out-GridView

The script

Just copy-paste the code below and save it as a .PS1 file. You can also add the script to your profile so that the function is loaded whenever you open PowerShell.

<#
.Synopsis
   Get a list of the installed applications on a (remote) computer.
.DESCRIPTION
Using WMI (Win32_Product), this script will query a (remote) computer for all installed applications and output the results.
   If required, these results can be exported or printed on screen.
   Please keep in mind that you need to have access to the (remote) computer’s WMI classes.
.EXAMPLE
   To simply list the installed applications, use the script as follows:
   
   Get-InstalledApplications -computer <computername>

.EXAMPLE
   If required, the output of the script can be modified. For instance, viewing the results on screen:
   
   Get-InstalledApplications -computer <computername> | Out-GridView
#>
function Get-InstalledApplications
{
   [CmdletBinding()]
   [OutputType([int])]
   Param
   (
      # defines what computer you want to see the inventory for
      [Parameter(Mandatory=$true,
      ValueFromPipelineByPropertyName=$true,
      Position=0)]
      $computer
   )

   Begin
   {
   }

   Process
   {
      $win32_product = @(get-wmiobject -class ‘Win32_Product’ -computer $computer)

      foreach ($app in $win32_product){
         $applications = New-Object PSObject -Property @{
         Name = $app.Name
         Version = $app.Version
         }

         Write-Output $applications | Select-Object Name,Version
      }
   }

   End
   {
   }
}

2 comments

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s