question

PetrDymacek-5216 avatar image
0 Votes"
PetrDymacek-5216 asked RichMatheisen-8856 edited

reading registry values on remote servers using a list of servers in PowerShell

I am a newbie to PowerShell and I need some help in writing a script. I have found out how to get the registry values from remote servers by the following reg query command:
reg query \\servername\HKLM\SYSTEM\CurrentControlSet\Services\Disk

What I would like to do is the following:
Setup a server.txt file that I can populate with the names of remote servers I need to query the registry on from my laptop. Next I would like to read registry values for TimeOutValue that will display on the screen for different servers. I know this is probably elementary to the experts, but I would really appreciate any assistance.

Thank you

windows-server-powershell
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

RichMatheisen-8856 avatar image
0 Votes"
RichMatheisen-8856 answered RichMatheisen-8856 edited

If you're going to do this on multiple computers you might as well do it on a bunch of them at a time! Something like this:

 Invoke-Command -Computer (get-content c:\junk\servers.txt) -ScriptBlock {Get-ItemProperty -Path: HKLM:SYSTEM\CurrentControlSet\Services\Disk -Name TimeOutValue}

The plain-text file "servers.txt" would hold the name of each server on a separate line.

If you'll take a suggestion you won't regret, read this (it's downloadable and it's free): Windows-PowerShell-4


· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi RichMatheisen-8856

Thank you very much, this work nicely , would you help me one more time , to have the output show just the PSComputerName and the Value for time out , if this possible ? and do output to text file
Thak you again

57894-powersehll-cem.jpg


0 Votes 0 ·
powersehll-cem.jpg (84.4 KiB)

Like this:


 Invoke-Command -Computer (get-content c:\junk\servers.txt) -ScriptBlock {
     Get-ItemProperty -Path: HKLM:SYSTEM\CurrentControlSet\Services\Disk -Name TimeOutValue 
 } | 
     Select-Object PSComputerName, TimeOutValue |
         Out-File c:\temp\timeoutvalue.txt


0 Votes 0 ·