Check registry for key value for remote servers/computers

I’ve had a couple of requests from customers this week to check for the presence of a specific registry key.  One looking for 2008/2008R2 servers: Get-ADComputer -Filter {OperatingSystem -Like “Windows Server* 2008”} -Properties * or others against a security group : Get-ADComputer -filter * -Property * | where {$_.memberof -match ‘YOURGROUPNAMEHERE’}.  Here’s a sample of it to check for all systems with .NET 4.6.2 installed and outputs it to a text file:

$PatchStatus=@{}
$RemoteSystems= Get-ADComputer -filter * -Property *
$RemoteHosts = $RemoteSystems.Name

foreach ($RemoteHost in $RemoteHosts){
$Hive = [Microsoft.Win32.RegistryHive]”LocalMachine”;
$RegKey = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey($Hive,$RemoteHost);
$Ref = $RegKey.OpenSubKey(“SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full\”);
$RefValue = $Ref.GetValue(“Release”)
if ($RefValue -ge “394806”){$PatchStatus.Add($RemoteHost,”Patched”)}
else {$PatchStatus.Add($RemoteHost,”Needs .NET”)}
}

$PatchStatus | Out-File “C:\Temp\Needs-DotNET4.6.2.txt”

About AJ McKean

Based in sunny Tauranga, New Zealand, AJ McKean is a Senior Systems Engineer in Mt Maunganui. With over 15 years of professional IT experience working in both New Zealand and the United States, he holds several certifications including MCSE(2000-2003), MCITP:Enterprise(2008), MCSA(2012), VMware VCP-DCV5.5, CompTIA A+ & is an HP Storage Architect. He is passionate about all things IT, especially virtualization, automation & cloud technologies.

Leave a Reply

Your email address will not be published. Required fields are marked *