Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Get OEMInformation from list of workstations

$
0
0
I am trying to get registry keys with the value OEMInformation from a list of computers but can't seem to get it to work. What am I missing?

$strMachineName = import-csv C:\temp\PCs.csv
foreach ($line in $strMachineName)
{
    try {
        $reg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine', $line.computer)
        $regkey = $reg.OpenSubkey("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion")
        $serialkey = $regkey.GetValue("OEMInformation")

        ('"{0}","{1}"' -f $line.computer, $OEMInformation) | out-file C:\temp\stdout.csv -append -encoding ascii
    } catch {
        ('"{0}","{1}"' -f $line.computer, $_) | out-file C:\temp\stderr.csv -append -encoding ascii
    }
}

Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>