September 23rd, 2014

PowerTip: Read First Line of File with PowerShell

Doctor Scripto
Scripter

Summary: Learn how to read only the first line of a file by using Windows PowerShell.

Hey, Scripting Guy! Question How can I use Windows PowerShell to read only the first line of a file?

Hey, Scripting Guy! Answer Introduced in Windows PowerShell 3.0, you can use the -First parameter, for example:

Get-Content C:\fso\batteryReport.txt -First 1

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.