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

Remote Registry Help

$
0
0

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

 

At line:1 char:93

+ ... uter.Computer)

$regkey=$reg.OpenSubkey('SOFTWARE\Microsoft\Windows\CurrentVersio ...

+                    ~~~~~~~~~~~~~~~~~~~~~~~

Unexpected token '$regkey=$reg.OpenSubkey' in expression or statement.

At line:1 char:177

+ ... mInformation') New-Object PsObject -Property @{ ComputerName =

$Computer.compute ...

+                    ~~~~~~~~~~

Unexpected token 'New-Object' in expression or statement.

At line:1 char:243

+ ... mputer.computer

+                    ~

The hash literal was incomplete.

    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordEx

   ception

    + FullyQualifiedErrorId : UnexpectedToken

 

this is the code

$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