powershell or bat - counting files in all directories and subdirec

we have a hardrive with hundreds of thousands of files

i need to figure out how many of every file extension we have

how can i do this with windowspowershell or command prompt or what ever else is available??

i need it to go through every directory. this lawyers at my company need this. it can be a total for the entire hardrive it does not have to be broken down by directory

example:

1232 JPEG
11 exe
45 bat
2342 avi
532 doc

Solution 1:

dir -recurse | group-object Extension -noelement

Solution 2:

Just because I can: A quick and dirty cmd solution that's not much longer than the PowerShell one:

(for /r %f in (*) do @(set /a EXT:%~xf+=1 >nul 2>&1))&set EXT: