Skip to content

Retrieves a list of all installed Windows updates on a local machine (a Windows PowerShell script).

License

Notifications You must be signed in to change notification settings

auberginehill/get-installed-windows-updates

Repository files navigation

Get-InstalledWindowsUpdates.ps1

OS: Windows
Type: A Windows PowerShell script
Language: Windows PowerShell
Description:

Get-InstalledWindowsUpdates uses Windows Management Instrumentation (WMI, with a command "Get-WmiObject -Class Win32_QuickFixEngineering" (Method 1)) to retrieve a list of some HotFixIDs installed on a local machine and displays the results in console. The Windows Management Instrumentation Command-Line Utility (WMIC.exe with the query path of win32_quickfixengineering (Method 2)) is then used to write a secondary CSV-file (partial_hotfix_list.csv) to $path – this secondary CSV-file populated by WMIC.exe contains about the same partial results as which were obtained by using the previous Method 1.

Finally, Get-InstalledWindowsUpdates uses Windows Update Agent (WUA) API (Method 3) to retrieve a third – comprehensive – list of all the installed and uninstalled Windows updates, and displays those results in a pop-up window and writes them to a CSV-file (installed_windows_updates.csv). This script is based on Stéphane van Gulick's PowerShell function "Get-WindowsUpdates".

Homepage: https://github.com/auberginehill/get-installed-windows-updates
Short URL: http://tinyurl.com/gtcktwy
Version: 1.3
Sources: Emojis: Emoji Table
Microsoft TechNet: How to List All of the Windows and Software Updates Applied to a Computer
ScriptingGuy1: How Can I Tell Which Service Packs Have Been Installed on a Computer?
Anna Wang: Cannot index into a null array
Stéphane van Gulick: Get-WindowsUpdates
Downloads: For instance Get-InstalledWindowsUpdates.ps1. Or everything as a .zip-file.

Screenshot

screenshot

Outputs

➡️
  • Displays a partial list of installed HotFixIDs in console and a list of all installed Windows updates in a pop-up window "$windows_updates_sorted_selection" (Out-GridView). Also writes two CSV-files at $path.

  • A pop-up window (Out-GridView):
    1. Name Description
      $windows_updates_sorted_selection Displays a list of installed Windows updates

  • And also two CSV-files at $path.
    1. Path Type Name
      $env:temp\partial_hotfix_list.csv CSV-file partial_hotfix_list.csv
      $env:temp\installed_windows_updates.csv CSV-file installed_windows_updates.csv

Notes

⚠️
  • Please note that the files are created in a directory, which is specified with the $path variable (at line 10).

  • 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 Computer icon and select Properties (or select Start → Control Panel → System. On Windows 10 this instance may also be found by right clicking Start and selecting Control Panel → System... or by pressing [Win-key] + X and selecting Control Panel → System). On the window with basic information about the computer...
    2. Click on Advanced system settings on the left panel and select Advanced tab on the "System Properties" pop-up window.
    3. Click on the button near the bottom labeled Environment Variables.
    4. In the topmost section, which lists the 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 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-InstalledWindowsUpdates
    Runs the script. Please notice to insert ./ or .\ before the script name.
  2. help ./Get-InstalledWindowsUpdates -Full
    Displays the help file.
  3. Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope LocalMachine
    This command is altering the Windows PowerShell rights to enable script execution in the default (LocalMachine) scope, and defines the conditions under which Windows PowerShell loads configuration files and runs scripts in general. In Windows Vista and later versions of Windows, for running commands that change the execution policy of the LocalMachine scope, Windows PowerShell has to be run with elevated rights (Run as Administrator). The default policy of the default (LocalMachine) scope is "Restricted", and a command "Set-ExecutionPolicy Restricted" will "undo" the changes made with the original example above (had the policy not been changed before...). Execution policies for the local computer (LocalMachine) and for the current user (CurrentUser) are stored in the registry (at for instance the HKLM:\Software\Policies\Microsoft\Windows\PowerShell\ExecutionPolicy key), and remain effective until they are changed again. The execution policy for a particular session (Process) is stored only in memory, and is discarded when the session is closed.

    Parameters:

      Restricted Does not load configuration files or run scripts, but permits individual commands. Restricted is the default execution policy.
      AllSigned Scripts can run. Requires that all scripts and configuration files be signed by a trusted publisher, including the scripts that have been written on the local computer. Risks running signed, but malicious, scripts.
      RemoteSigned Requires a digital signature from a trusted publisher on scripts and configuration files that are downloaded from the Internet (including e-mail and instant messaging programs). Does not require digital signatures on scripts that have been written on the local computer. Permits running unsigned scripts that are downloaded from the Internet, if the scripts are unblocked by using the Unblock-File cmdlet. Risks running unsigned scripts from sources other than the Internet and signed, but malicious, scripts.
      Unrestricted Loads all configuration files and runs all scripts. Warns the user before running scripts and configuration files that are downloaded from the Internet. Not only risks, but actually permits, eventually, running any unsigned scripts from any source. Risks running malicious scripts.
      Bypass Nothing is blocked and there are no warnings or prompts. Not only risks, but actually permits running any unsigned scripts from any source. Risks running malicious scripts.
      Undefined Removes the currently assigned execution policy from the current scope. If the execution policy in all scopes is set to Undefined, the effective execution policy is Restricted, which is the default execution policy. This parameter will not alter or remove the ("master") execution policy that is set with a Group Policy setting.
      Notes:
      • Please note that the Group Policy setting "Turn on Script Execution" overrides the execution policies set in Windows PowerShell in all scopes. To find this ("master") setting, please, for example, open the Local Group Policy Editor (gpedit.msc) and navigate to Computer Configuration → Administrative Templates → Windows Components → Windows PowerShell.
      • The Local Group Policy Editor (gpedit.msc) is not available in any Home or Starter edition of Windows.
        1. Group Policy Setting "Turn on Script Execution" PowerShell Equivalent (concerning all scopes)
          Not configured No effect, the default value of this setting
          Disabled Restricted
          Enabled – Allow only signed scripts AllSigned
          Enabled – Allow local scripts and remote signed scripts RemoteSigned
          Enabled – Allow all scripts Unrestricted

    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-InstalledWindowsUpdates.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 and/or the filename includes space characters, please enclose the whole -Path parameter value in quotation marks (single or double):

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

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

Contributing

contributing Bugs: Bugs can be reported by creating a new issue.
Feature Requests: Feature request can be submitted by creating a new issue.
Editing Source Files: New features, fixes and other potential changes can be discussed in further detail by opening a new pull request.

www

www Script Homepage
Microsoft TechNet: How to List All of the Windows and Software Updates Applied to a Computer
ScriptingGuy1: How Can I Tell Which Service Packs Have Been Installed on a Computer?
Anna Wang: Cannot index into a null array
Stéphane van Gulick: Get-WindowsUpdates
Jan Egil Ring: Invoke-WindowsUpdate
Manage Windows Update installations using Windows PowerShell
Manage Windows Update installations using Windows PowerShell
Managing Windows Update with PowerShell
Appendix B. Regular Expression Reference
How to Use PowerShell to Run Windows Updates
Using the Windows Update Agent API
OperationResultCode enumeration
ServerSelection enumeration
UpdateOperation enumeration
IUpdateHistoryEntry interface
The String's the Thing
Dig Deep into your system with Dedicated System Information Tools in Windows 7
Why are "get-hotfix" and "wmic qfe list" in Powershell missing installed updates?
Why is there a DAILY update for English Input Personalization Dictionary
ASCII Art: http://www.figlet.org/ and ASCII Art Text Generator

Related scripts

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

About

Retrieves a list of all installed Windows updates on a local machine (a Windows PowerShell script).

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published