Powershell file counter

Ever wondered how many files you got in a directory? Just open up powershell and go to the folder you want to search, then paste this line of code.
Please note that this also counts folders, not just files.

$i=0; foreach ($element in $(cmd /c dir /b /s .).split("`n")){$i++}; Write-Host $i