Hello All,
I am struck finding a way to list the installed updates remotely in the same ways as that of Programs and Features. Can someone please guide me which commands can be used ?
Hello All,
I am struck finding a way to list the installed updates remotely in the same ways as that of Programs and Features. Can someone please guide me which commands can be used ?
What exactly do you mean with:
What have you tried so far? Get-Hotfix lists the installed Windows updates from remote computers as well.
I just went through scripting this. Not 100% like Programs and features/View installed updates, but pretty close. Here is the function I wrote for that. Perhaps the guru’s on this site can suggest improvements. This might at least get you started.
Function Get-PatchList {
<#
This function will grab the patches from the registry in an attempt to report the same information as "View Installed Updates"
from Control Panel/Programs and Features.
#>
param(
[String] $hostToCheck
)
$aryUpdates = @()
$PatchRegPath = 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\*\Products\*\Patches\*'
# Figure out remote or local and connect to the registry accordingly
if(!($hostToCheck -Match $ENV:ComputerName)) {
try {
$Updates = Invoke-Command -ComputerName $hostToCheck -ScriptBlock {Get-ItemProperty -Path $Using:PatchRegPath}
}
catch {
Return $_.Exception.Message
}
}
else {
try {
$Updates = Get-ItemProperty -Path $PatchRegPath
}
catch {
Return $_.Exception.Message
}
}
$Updates | foreach-Object {
$UpdateInfo = [PSCustomObject][Ordered] @{
'Patch/Update Name' = $_.DisplayName
'Install Date' = $_.Installed.SubString(0,4)+'-'+$_.Installed.SubString(4,2)+'-'+$_.Installed.SubString(6,2)
'Uninstallable' = $_.Uninstallable
}
$aryUpdates += $UpdateInfo
}
$aryUpdates = $aryUpdates | Sort-Object -Property 'Patch/Update Name' -Unique | Sort-Object -Property 'Install Date' -Descending
Return $aryUpdates
}