Powershell query

leadtheway
leadtheway used Ask the Experts™
on
Trying to run a script that will query a txt file before running the query and action against each.  I have one that does if i manually put the server name but i would like to just do a text file due to the amount of machines.

$ComputerName = @('server2012', 'vista64esxi', 'server2008')
foreach ($Computer in $ComputerName) {
    if ($Status = Get-Service -ComputerName $Computer -Name RemoteRegistry -EA SilentlyContinue |

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2014
Commented:
Just replace $ComputerName = @('server2012', 'vista64esxi', 'server2008') with
$ComputerName = Get-Content servers.txt

Open in new window

Where "servers.txt" is a file that is just a simple list of computers, one per line.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial