powershell - Remote Registry List of PCs -
i trying remote registry values oeminformation
key list of computers, cant seem work. error:
exception calling "openremotebasekey" "2" argument(s): "the network path not found"
what missing?
$strmachinename = import-csv c:\temp\pcs.txt foreach ($line in $strmachinename) { try { $reg = [microsoft.win32.registrykey]::openremotebasekey('localmachine', $computer) $regkey=$reg.opensubkey('software\microsoft\windows\currentversion\oeminformation') 'model:{0} manufactured by:"{1}"' -f $regkey.getvalue('model'),$regkey.getvalue('manufacturer') } catch{ write-host "$_" -fore red } } $results|export-csv c:\temp\pcs-results.csv -notype
the $computer
-variable referring in following line, doesn't exist.
[microsoft.win32.registrykey]::openremotebasekey('localmachine', $computer)
does content of txt-file have header? ex:
computer machine1 machine2
then try
[microsoft.win32.registrykey]::openremotebasekey('localmachine', $line.computer)
if txt-file contains 1 machinename per line , no headers, replace import-csv
get-content
, try
[microsoft.win32.registrykey]::openremotebasekey('localmachine', $line)
Comments
Post a Comment