Last 3 updates on all DCs

I have this code to look for the last update installed, per DC but it shows all updates

$DCs = [DirectoryServices.ActiveDirectory.Domain]::GetCurrentDomain() |
        Select-Object -ExpandProperty DomainControllers |
            Select-Object -ExpandProperty Name

Foreach ($DC in $DCS){		
    Invoke-Command -ComputerName $DC {
        (Get-HotFix | Sort-Object -Property InstalledOn[-1]  )

How would I restrict to just the last 3 updates?

After sorting the list you select the first or the last 3 elements with Select-Object -Last 3 or Select-Object -First 3 !?! :thinking:

1 Like