Count files by extension using powershell

I found this beautiful code somewhere on the internet by which we can get the count of all files as per their extensions. I mainly needed this code while migration of on-prim file services to the cloud. So, I thought to share it on my blog to spread it more.
I have modified the code a little bit to give more better results.

$path = "\path\to\the\folder"
$output = "\path\to\the\file"
$count = Get-Childitem $path -Recurse -ErrorAction SilentlyContinue | where { -not $_.PSIsContainer } | group Extension -NoElement | sort count -desc
$count >> $output

Output

0 comments:

Post a Comment