Skip to content

Instantly share code, notes, and snippets.

@devynspencer
Created September 1, 2016 22:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save devynspencer/8c3f4381ef147c1ff7a33a9bc69e7b45 to your computer and use it in GitHub Desktop.
Save devynspencer/8c3f4381ef147c1ff7a33a9bc69e7b45 to your computer and use it in GitHub Desktop.
Get the installation time for the last successful update to a server.
foreach ($Server in $servers) {
$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
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment