Friday, February 20, 2015

Reading values from text file using PowerShell Script

text file name : ReadData.txt

The file contains values
Red
Blue
Yellow
Violet
Orange

PowerShell Script Reading data from text values:

$Location = get-location;
$PackagePath = $Location.tostring()
$textPath= $PackagePath + "\ReadData.txt"

$DataValue = get-content $textPath

foreach ($data in $DataValue)
 {
      Write-Host("The value from the text :" + $data)
      Write-Host(" ")
 }