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

Remote Registry

$
0
0

I am trying to start the remote registry service for each PC to fetch a value from the registry but going nowhere. 

$Computers = import-csv C:\temp\PCs.csv

$results=foreach ($Computer in $Computers) {

(Get-WmiObject -computerName $Computers Win32_Service -Filter "Name='RemoteRegistry'").StartService() | Out-Null         

$reg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine', $Computer.Computer)

         $regkey=$reg.OpenSubkey('SOFTWARE\Microsoft\Windows\CurrentVersion\OemInformation')

          New-Object PsObject -Property @{

ComputerName = $Computer.computer                                                                          

Model=$regkey.GetValue('Model')

                                                                          Manufacturer=$regkey.GetValue('Manufacturer')

    (Get-WmiObject -computerName $Computers Win32_Service -Filter "Name='RemoteRegistry'").StopService() | Out-Null                                                                      }

          }

$results|Export-Csv C:\temp\PCsResults.csv -NoType


Viewing all articles
Browse latest Browse all 6937

Trending Articles