Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Issue with Microsoft.Win32.RegistryKey going thru a server list.

$
0
0
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

Viewing all articles
Browse latest Browse all 6937

Trending Articles