# StevensNet.com

## Blogs

To return to the main Blog List, click Full Blog Listing.

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

Friday, April 03, 2015 in Powershell (Views: 1406)
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
}

Your output would be:
ping -t CLIENT1
ping -t CLIENT2
ping -t CLIENT3

Happy scripting...