Created
September 1, 2016 22:34
-
-
Save devynspencer/8c3f4381ef147c1ff7a33a9bc69e7b45 to your computer and use it in GitHub Desktop.
Get the installation time for the last successful update to a server.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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