I had to count SLOC and files for a POC of a static analysis tool
The SLOC were counted using:
ls * -recurse -include *.aspx, *.ascx, *.cs, *.ps1 | Get-Content | Measure-Object -Line
The files were counted using
(Get-ChildItem -force -recurse).Count
Guddam PowerShell. Rocks. So. Hard.