Read Line by Line in a Loop from a Text File using PowerShell

How to use PowerShell to read a line from a text file.

First read from a text file using Powershell. Then using the loop named FOREACH.

$file = Get-Content "C:\File.txt"

foreach ($line in $file) 
{
    Write-Output "The name is: $line"
}
PowerShell

Comments