Hello,
I'm trying to get the value of a registry key value.
I have this code and it works on when I query my workstation.
We I configure it to read it from a server list it seems to keep pulling in the value on my workstation and not the server value.
# PowerShell Registry Key Clear-Host$results=Get-Content-Pathc:\temp\servers.txt | ForEach-Object { $reg= [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine', $_) $KeyPath="SOFTWARE\Wow6432Node\Bit9\Parity Agent\ServerSettings"$regKey=$reg.OpenSubKey($KeyPath)if ($regKey-eq$null)
{$found="Registry Key Not Found"
} else
{$found= (get-ItemProperty-Path HKLM:\$keypath).B9_HOST_ENFORCEMENT
}
[PSCustomObject]@{
MachineName =$_
EnforcementLevel =$found
}
}$results |Export-CSV-pathc:\temp\bit9_64bit.csv-append-NoTypeInformation-EncodingUTF8