Export (0) Print
Expand All
Expand Minimize

Converting the FileSystemObject's AtEndOfLine Property


Windows PowerShell


Definition: When reading through a text file one character at a time, returns True when you reach the end of a line.

AtEndOfLine


Because file contents and strings are arrays in PowerShell, the end of line can be found simply by checking for the Length of the array.

Here we use the Get-Content cmdlet with the -totalcount parameter set to 1 to retrieve the first line of the file test.txt. We then set up a for loop to loop through the characters in this line, up to the number of characters in the line ($a.length), echoing each individual character each time through the loop:


$a = Get-Content c:\scripts\test.txt -totalcount 1
for ($i = 0; $i -lt $a.length; $i++)
{
    $a[$i]
}


See conversions of other FileSystemObject methods and properties.
Return to the VBScript to Windows PowerShell home page

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft