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

Petr Dymacek 21 Reputation points
2021-01-13T19:17:40.257+00:00

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
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,408 questions
0 comments No comments
{count} votes

Accepted answer
  1. Rich Matheisen 45,111 Reputation points
    2021-01-13T20:10:35.207+00:00

    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


0 additional answers

Sort by: Most helpful