PowerShell: Count your Code lines
After Coding some lines in a lot of different files you wanna know how much lines you have coded. There are two (I am sure there are even more) ways to do that. The first one is to get the content of the files (
Get-Content) and count the lines in there. With the Select-String cmdlet, you can count your code lines in a file or script using PowerShell.
The other way and the faster way is with Select-String:
(Get-ChildItem -Include *.ps1 -Recurse | Select-String -pattern .).Count
You can find more about Select-String on Microsoft Docs.
I hope this gives you an idea how you can count your lines of codes in PowerShell. Also have a look at at my blog post about how to install PowerShell 6 and PowerShell 7. If you have question, let me know in the comments.