Export (0) Print
Expand All
Expand Minimize

Converting the FileSystemObject's ReadLine Method


Windows PowerShell


Definition: Reads a single line from a text file.

ReadLine



Get-Content C:\Scripts\test.txt -totalcount 1


Get-Content returns lines of text from a file as an array, which means you can also read all the contents then access individual lines by accessing the associated array item. For example, this code returns the third line (array item 2) from the file:


(Get-Content C:\Scripts\test.txt)[2]


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