I am using powershell to read a text file which has text in lines and display items. How do I use parallel foreach instead of foreach. I tried foreach and it works but foreach parallel syntax didnt work.
$lines = Get-Content myFile.txt | Where {$_ -notmatch '^\s+$'}
Foreach ($Item in $lines)
{
$Item
}
MyFile.Txt
newyork is great
seattle is cold
florida is hot
This is what I tried
$lines = Get-Content myFile.txt | Where {$_ -notmatch '^\s+$'}
ForEach -Parallel ($Item in $lines)
{
$Item
}
Error: -parallel an be used only in workflow