January 20th, 2016

PowerTip: Use PowerShell to return first two lines of file

Doctor Scripto
Scripter

Summary: Learn how to use Windows PowerShell to return the first two lines of a text file.

Hey, Scripting Guy! Question How can I use Windows PowerShell to easily return the first two lines of a text file?

Hey, Scripting Guy! Answer Use the Get-Content cmdlet and specify the TotalCount parameter. In this example, TotalCount is set
           to 2 and the file is named AMoreComplete.txt:

Get-Content ‘C:\fso\AMoreComplete.txt’ -TotalCount 2

Category
Scripting

Author

The "Scripting Guys" is a historical title passed from scripter to scripter. The current revision has morphed into our good friend Doctor Scripto who has been with us since the very beginning.

0 comments

Discussion are closed.

Feedback