# This script shows the last time that a successfull Windows Update was installed.
cls
add-PSSnapin quest.activeroles.admanagement
$OnlineServers = @()
Get-QADComputer -SearchRoot 'domain.com/Terminal Servers/Production 1' -OSName "Windows*Server*" | where {$_.accountisdisabled -eq $false} | % {
$PingResult = Get-WmiObject -Query "SELECT * FROM win32_PingStatus WHERE address='$($_.Name)'"
If ($PingResult.StatusCode -eq 0) {
# Add the current name to the array
$OnlineServers += "$($_.Name)"
}
}
foreach ($Server in $OnlineServers ) {
$key = "SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\Results\Install"
$keytype = [Microsoft.Win32.RegistryHive]::LocalMachine
$RemoteBase = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey($keytype,$Server)
$regKey = $RemoteBase.OpenSubKey($key)
$KeyValue = $regkey.GetValue("LastSuccessTime")
$System = (Get-Date -Format "yyyy-MM-dd hh:mm:ss")
if ($KeyValue -lt $System) {
Write-Host " "
Write-Host $Server "Last time updates were installed was: " $KeyValue
}
}
Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.
When asked, what has been your best career decision?
Deciding to stick with EE.
Being involved with EE helped me to grow personally and professionally.
Connect with Certified Experts to gain insight and support on specific technology challenges including:
We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE