Share via


Powershell: Export Hotfix details of Remote Computers

Method Used

PowerShell Scripting

Tested Versions

PowerShell v2, v3, v4 and v5

Operating systems used

Windows 10, Windows Server 2012, Windows Server 2016 Technical Preview 4

Procedure

There are several commands to get installed hotfix details of a local computer.

To get those details, open the PowerShell console and execute the command.

Get-hotfix

For example

https://gallery.technet.microsoft.com/site/view/file/152983/1/1.jpg

 

The output will display the source computer name, type of patch whether it is Update or security patch, Hotfix ID, Date and time of installation. We can use the pipe to filter the current output as per our requirement.

The same one liner command can be used for checking hotfix details of remote computers. For that, we need to use -computername switch with get-hotfix command. After **-*computername ***we need to specify the remote computername. The command will look like as shown below.

Get-hotfix -computername <host name of Remote Computer>

For Example

** **

https://gallery.technet.microsoft.com/site/view/file/152984/1/2.jpg

The above one liner command will be useful for export patch installation details of one or two hosts. But if we need to export hotfix installation of multiple remote computers, it will be time-consuming.

Here we are explaining a small script which is used to export details of updated patches of multiple remote computers without any headache.

Download script

 https://gallery.technet.microsoft.com/How-to-Export-Hotfix-e61e9782

We used same one-line command here but instead of computer name used a variable called $server.

That means the command will take the computer name as a variable. For that, we need to provide a list of computers list named computers.txt. ***The computers.txt *** file contains all servers details one by one. You can use both hostnames and IP address.

For demo purposes, we have used three hostnames as shown in below example.

Example

 

 https://gallery.technet.microsoft.com/site/view/file/152985/1/3.jpg

How to run the script:
  • Copy the exporthotfix.ps1 and computers.txt file in a single folder.
  • Open the PowerShell as an administrator and disable the script execution restriction by entering the below command:

Set-executionpolicy unrestricted

 https://gallery.technet.microsoft.com/site/view/file/152988/1/4.jpg

Press Y to confirm.

  • Right click the script and select Run with PowerShell.
  • The output will be saved in C:\windows\temp. You can modify the output path by modifying the script.

 

 https://gallery.technet.microsoft.com/site/view/file/152987/1/5.jpg

 

https://gallery.technet.microsoft.com/site/view/file/152989/1/6.jpg

 

https://gallery.technet.microsoft.com/site/view/file/152990/1/7.jpg

 

Here we used to export the contents as a CSV format. If you need to export the output as a TXT format modify the below line in the script and save:

 

$QFE = Get-hotfix -computername $server | select-object -property Description,HotFixID,InstalledBy,InstalledOn | out-file c:\windows\temp\$server.txt

 

 This time the output will save as a txt format.

 https://gallery.technet.microsoft.com/site/view/file/152991/1/8.jpg

https://gallery.technet.microsoft.com/site/view/file/152993/1/9.jpg

 


Other Languages

This article is also available in Turkish languages.

Türkçe (tr-TR)