Would you like to learn how to count lines in a text file using Powershell? In this tutorial, we are going to show you how to use Powershell to count the number of lines from a text file on a computer running Windows.
• Windows 2012 R2
• Windows 2016
• Windows 2019
• Windows 10
• Windows 7
Equipment list
The following section presents the list of equipment used to create this tutorial.
As an Amazon Associate, I earn from qualifying purchases.
Related tutorial – PowerShell
On this page, we offer quick access to a list of tutorials related to PowerShell.
Tutorial Powershell – Count lines from a file
Start a Powershell command-line.
Create a text file.
In our example, we create a text file named MYFILE in the root of drive C.
Count the number of lines from a file using Powershell.
Here is the command output.
Get only the number of lines from a file.
Here is the command output.
Congratulations! You are able to count the lines of a file using Powershell.