Skip to content

Retrieves the programs installed on a local machine. Additionally on a Windows 8 or Windows Server 2012 machine and later – depending whether the script is run in an elevated PowerShell window or not – some of or all the installed Windows Store apps (app packages (.appx)) are enumerated (a Windows PowerShell script).

License

Notifications You must be signed in to change notification settings

auberginehill/get-installed-programs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Get-InstalledPrograms.ps1

OS: Windows
Type: A Windows PowerShell script
Language: Windows PowerShell
Description: Get-InstalledPrograms queries the Windows registry for installed programs. The keys from HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\ and HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\ are read on 64-bit computers and on the 32-bit computers only the latter path is accessed. Basic program related properties, such as Name, Version, Install Date, Publisher, Comments, Contact, Icon, Estimated Size, Help Link, Install Location, Install Source, Language, Modify Path, NoModify, NoRepair, Partner Code, PSChildName, PSDrive, PSProvider, Uninstall String, URL Info (About), URL Update Info, Version (Real), Version Major, Version Minor and Windows Installer are written to a CSV-file and displayed in a pop-up window (Out-Gridview). On Windows 8 / Windows Server 2012 machines (and later) also the installed Windows Store apps are enumerated with the Get-AppxPackage cmdlet(, which requires PowerShell 3.0 or later) in a separate CSV-file and displayed in a pop-up window (Out-Gridview); If Get-InstalledPrograms is run in an elevated PowerShell window, the Apps that are installed under other than the current user profile are detected, too.

The enumeration of installed programs in a Windows machine may take some time – therefore a progress bar is included in Get-InstalledPrograms for monitoring the steps taken. Also, after the Get-InstalledPrograms is finished, a rudimentary summary about the performance of the machine is shown. Similarly, in "Code snippet 1" is described what is not included in Get-InstalledPrograms. The "Get-WmiObject -Class Win32_Product" query method was discarded mainly due to the excessive long running times. Please see the Notes section below for further debate on the notorious Win32_Product Class.

On the other hand, as described in "Code snippet 2", if it is relevant to find out, whether a particular version of a known program is installed or not, the here unused function Check-InstalledSoftware could be called to action (the code is taken from https://github.com/auberginehill/update-adobe-flash-player" and is quite quick):

Check-InstalledSoftware "Adobe Flash Player 23 NPAPI" 23.0.0.162

will return all the aforementioned info on the queried program, if it is installed, but returns a null value, if such a program doesn't exist on the machine.
Homepage: https://github.com/auberginehill/get-installed-programs
Short URL: http://tinyurl.com/j7a4eky
Version: 1.2
Sources:
Emojis: Emoji Table
Tobias Weltner: PowerTips Monthly vol 8 January 2014 (or one of the archive.org versions)
chocolatey: Flash Player Plugin
alejandro5042: How to run exe with/without elevated privileges from PowerShell
Michael Pietroforte: PowerShell versions and their Windows version
Downloads: For instance Get-InstalledPrograms.ps1. Or everything as a .zip-file.

Screenshot

screenshot

Outputs

➡️
  • Displays general program related information in console. In addition to that...

  • Two pop-up windows "$obj_installed_programs_selection_all" and "$windows_store_apps" (Out-GridView) on machines running Windows 8 / Windows Server 2012 or later. On machines with an earlier OS version only the former pop-up window is displayed. For determining the Operating System version, please see the Notes-section below.
    1. Name Description
      $obj_installed_programs_selection_all Enumerates the found installed programs
      $windows_store_apps Inventory of some or all the Windows Store apps; If Get-InstalledPrograms is run in an elevated PowerShell window, the Apps that are installed under other than the current user profile are detected, too.

  • And also two CSV-files at $path on machines running Windows 8 / Windows Server 2012 or later. On machines with an earlier OS version only the former file is written. For determining the Operating System version, please see the Notes-section below.
    1. Path Type Name
      $env:temp\installed_programs.csv CSV-file installed_programs.csv
      $env:temp\windows_store_apps.csv CSV-file windows_store_apps.csv

Notes

⚠️
  • Despite Get-InstalledPrograms makes valid eforts to detect the installed programs on a local machine, achieving a 100 % detect rate of the installed programs might not happen, since not every program writes the uninstallation information to the registry. The unused WMI query Get-WmiObject -Class Win32_InstalledWin32Program seems not to detect every installed program either, and even listing all the shortcuts found on a computer omits those programs, which don't have a shortcut, so increasing the detect rate of the hard-to-detect installed programs is clearly a prominent area for further development in Get-InstalledPrograms.

  • The notoriously slow and possibly harmful Get-WmiObject -Class Win32_Product command is deliberately not used for listing the installed programs in Get-InstalledPrograms, since the Win32_Product Class has some unpleasant behaviors – namely it uses a provider DLL that validates the consistency of every installed MSI package on the computer (msiprov.dll with the mandatorily initiated resiliency check, in which the installations are verified and possibly also repaired or repair-installed), which is the main reason behind the slow performance of Win32_Product Class. All in all Win32_product Class is not query optimized and in Get-InstalledPrograms, for now, a combination of various registry queries is used instead.
  • PowerShell versions and their Windows versions:
      PowerShell version1 Release Date Default on Windows This PowerShell Version is also available on Windows Version(s)
      Version8 OSVersion2
      Win3.16 ?.?
      Win957 4.0
      Win987 4.10
      WinME7 4.90
      NT 3.51 3.51
      NT 4.0 4.0
      Windows 2000 5.0
      Windows XP 5.1
      Windows XP 64-Bit Edition 5.2
      Windows Server 2003 5.2
      Windows Server 2003 R2 5.2
      Windows Vista 6.0
      PowerShell 1.0 November 2006 Windows Server 20083 6.0 Windows XP SP2
      Windows XP SP3
      Windows Vista
      Windows Vista SP2
      Windows Server 2003 SP1
      Windows Server 2003 SP2
      Windows Server 2003 R2
      PowerShell 2.0 October 2009 Windows 7 6.1 Windows XP SP3
      Windows Vista SP1
      Windows Vista SP2
      Windows Server 2008 R24 6.1 Windows Server 2003 SP2
      Windows Server 2008 SP1
      Windows Server 2008 SP2
      PowerShell 3.0 September 2012 Windows 8 6.2 Windows 7 SP1
      Windows Server 2012 6.2 Windows Server 2008 SP2
      Windows Server 2008 R2 SP1
      PowerShell 4.0 October 2013 Windows 8.1 6.3 Windows 7 SP1
      Windows Server 2012 R2 6.3 Windows Server 2008 R2 SP1
      Windows Server 2012
      PowerShell 5.0 April 20145 Windows 10 10.0 Windows 7 SP19
      Windows 8.1
      Windows Server 2016 10.0 Windows Server 2008 R29
      Windows Server 2012
      Windows Server 2012 R2

      1 $PSVersionTable.PSVersion
      2 [System.Environment]::OSVersion.Version (format: Major.Minor – requires .NET Framework 1.1 or later; To find out the .NET Framework version with PowerShell, a command $PSVersionTable.CLRVersion could be used).
      3 Has to be installed through Server Manager
      4 Also integrated in all later Windows versions
      5 Release date of public review
      6 Platform ID = 0
      7 Platform ID = 1 (whereas on NT 3.51 and later the Platform ID ≥ 2)
      8 (Get-WmiObject -Class Win32_OperatingSystem).Caption
      9 Requires .NET Framework 4.5

      Sources: PowerShell versions and their Windows version, Get operating system information in VB .NET, Operating System Version, Install and Configure WMF 5.1 and System.Environment.OSVersion.Version.Major

  • Please note that this script will try to check whether it is run in an elevated PowerShell window (run as an administrator) or not when executed on a Windows 8 or a Windows Server 2012 machine or later.
  • Please note that the CSV-file is created in a directory, which is specified with the $path variable (at line 6). The $env:temp variable points to the current temp folder. The default value of the $env:temp variable is C:\Users\<username>\AppData\Local\Temp (i.e. each user account has their own separate temp folder at path %USERPROFILE%\AppData\Local\Temp). To see the current temp path, for instance a command

    [System.IO.Path]::GetTempPath()

    may be used at the PowerShell prompt window [PS>]. To change the temp folder for instance to C:\Temp, please, for example, follow the instructions at Temporary Files Folder - Change Location in Windows, which in essence are something along the lines:
    1. Right click on Computer and click on Properties (or select Start → Control Panel → System). In the resulting window with the basic information about the computer...
    2. Click on Advanced system settings on the left panel and select Advanced tab on the resulting pop-up window.
    3. Click on the button near the bottom labeled Environment Variables.
    4. In the topmost section labeled User variables both TMP and TEMP may be seen. Each different login account is assigned its own temporary locations. These values can be changed by double clicking a value or by highlighting a value and selecting Edit. The specified path will be used by Windows and many other programs for temporary files. It's advisable to set the same value (a directory path) for both TMP and TEMP.
    5. Any running programs need to be restarted for the new values to take effect. In fact, probably also Windows itself needs to be restarted for it to begin using the new values for its own temporary files.

Examples

📖 To open this code in Windows PowerShell, for instance:

  1. ./Get-InstalledPrograms
    Run the script. Please notice to insert ./ or .\ before the script name.
  2. help ./Get-InstalledPrograms -Full
    Display the help file.
  3. Set-ExecutionPolicy remotesigned
    This command is altering the Windows PowerShell rights to enable script execution for the default (LocalMachine) scope. Windows PowerShell has to be run with elevated rights (run as an administrator) to actually be able to change the script execution properties. The default value of the default (LocalMachine) scope is "Set-ExecutionPolicy restricted".

    Parameters:

      Restricted Does not load configuration files or run scripts. Restricted is the default execution policy.
      AllSigned Requires that all scripts and configuration files be signed by a trusted publisher, including scripts that you write on the local computer.
      RemoteSigned Requires that all scripts and configuration files downloaded from the Internet be signed by a trusted publisher.
      Unrestricted Loads all configuration files and runs all scripts. If you run an unsigned script that was downloaded from the Internet, you are prompted for permission before it runs.
      Bypass Nothing is blocked and there are no warnings or prompts.
      Undefined Removes the currently assigned execution policy from the current scope. This parameter will not remove an execution policy that is set in a Group Policy scope.

    For more information, please type "Get-ExecutionPolicy -List", "help Set-ExecutionPolicy -Full", "help about_Execution_Policies" or visit Set-ExecutionPolicy or about_Execution_Policies.

  4. New-Item -ItemType File -Path C:\Temp\Get-InstalledPrograms.ps1
    Creates an empty ps1-file to the C:\Temp directory. The New-Item cmdlet has an inherent -NoClobber mode built into it, so that the procedure will halt, if overwriting (replacing the contents) of an existing file is about to happen. Overwriting a file with the New-Item cmdlet requires using the Force. If the path name includes space characters, please enclose the path name in quotation marks (single or double):

      New-Item -ItemType File -Path "C:\Folder Name\Get-InstalledPrograms.ps1"

    For more information, please type "help New-Item -Full".

Contributing

Find a bug? Have a feature request? Here is how you can contribute to this project:

contributing Bugs: Submit bugs and help us verify fixes.
Feature Requests: Feature request can be submitted by creating an Issue.
Edit Source Files: Submit pull requests for bug fixes and features and discuss existing proposals.

www

www Script Homepage
Tobias Weltner: PowerTips Monthly vol 8 January 2014 (or one of the archive.org versions)
chocolatey: Flash Player Plugin
Perfect Progress Bars for PowerShell
Uninstall method of the Win32_Product class
How to run exe with/without elevated privileges from PowerShell
PowerShell versions and their Windows version
Get operating system information in VB .NET
System.Environment.OSVersion.Version.Major

Related scripts

www Disable-Defrag
Firefox Customization Files
Get-AsciiTable
Get-BatteryInfo
Get-ComputerInfo
Get-CultureTables
Get-DirectorySize
Get-InstalledWindowsUpdates
Get-PowerShellAliasesTable
Get-PowerShellSpecialFolders
Get-RAMInfo
Get-TimeDifference
Get-TimeZoneTable
Get-UnusedDriveLetters
Emoji Table
Java-Update
Remove-EmptyFoldersLite
Remove-EmptyFolders
Rename-Files
Rock-Paper-Scissors
Toss-a-Coin
Update-AdobeFlashPlayer
Update-MozillaFirefox

About

Retrieves the programs installed on a local machine. Additionally on a Windows 8 or Windows Server 2012 machine and later – depending whether the script is run in an elevated PowerShell window or not – some of or all the installed Windows Store apps (app packages (.appx)) are enumerated (a Windows PowerShell script).

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published