PowerTip: Read First Line of File with PowerShell

The Scripting Guys

Dr

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

The Scripting Guys
Dr Scripto

Follow Dr   

No Comment.