# StevensNet.com

## Sample PS to Read a fle and execute a command

Friday, April 03, 2015 in Powershell (Views: 1361)
So a simple blog, friend asked for it, so why not...

All you need to do is run a command against a list of systems in a text file, like such:
CLIENT1
CLIENT2
CLIENT3

To do this, simply run this PowerShell and add any commands within the {} brackets. Say, just to ping these systems, I'll use a local echo.

$FileName="c:\temp\text.txt" foreach ($SysName in get-content $FileName){ Write-Host "ping -t "$SysName
}