Reputation:
I'm currently extracting data from a text file and then attempting to perform an action for each entry in the text file. See code below.
$Employees = Get-Content C:\User\Documents\UserWorkstations.txt
Foreach($name in $Employees)
{
ping $name
}
After running my script it does not extract data from the text file and I get the following output:
cmdlet ForEach-Object at command pipeline position 2
Supply values for the following parameters:
Process[0]:
Upvotes: 0
Views: 2184
Reputation: 26779
Get-Content -Path 'C:\User\Documents\UserWorkstations.txt' |
Foreach-Object {
Write-Host ('Pinging {0}' -f $_)
ping $_
}
Upvotes: 1