Script to check if a reg key is set on multiple servers
Published Jun 19 2019 10:52 AM 4,806 Views



If your servers require a registry key and unsure if its properly configured. You can use this script to check if the key is present or is set to the correct value across multiple servers.

The Script


# Simple Server list
$servers = Get-Content C:\servers.txt
# Loop through all servers and check key 
foreach ($server in $servers) {
$REG = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine', $server)
$REGKEY = $REG.OpenSubKey("SYSTEM\CurrentControlSet\Control\Lsa")
$val = $REGKEY.GetValue("DisableLoopBackCheck")
# If the key is missing or not set it will be displayed in red
# If the key is set it will be displayed in green
if (!$val){
Write-Host $server "is not set"  -ForegroundColor Red

#specify the value here
if ($val -ne "1"){
Write-Host $server "is not set properly"  -ForegroundColor Red
Write-Host $server "is set" -ForegroundColor Green


What the Script Does


In the sample above it will check the “DisableLoopBackCheck” key across a list of servers and if the key does not exist or not set to “1” it will be reported in the output.





You can simply change which key to check and the desired value to make this work for your scenario.


I hope this helps make your job easier in the future.

Version history
Last update:
‎Jun 19 2019 10:56 AM
Updated by: