Monday, March 23, 2015

Read file in Powershell line by line

Reading  file in Powershell line by line can be helpful if you want do some operation on file

Example

Perform same operation for each line of file

1. Searching for specific words in line
2. navigating to different urls to check response
3. etc

I wrote this piece of code to update SharePoint Site logo for multiple site


$file= Get-Content("FileName")
foreach ($line in $file)
{
    Write-Host "One line from file"
    Write-Host $line
}

No comments:

Post a Comment