Powershell file query, sort, output

Have a very basic Powershell request, but my experience is even more basic. Please Humor me...
I need to Write a Windows PowerShell script that will perform the following functions:
1. Search the computer for files ending with a .doc, .docx, .xls, or .xlsx file extension.
2. Output the filenames and sizes (in groups by file extension) to a text file named “File_Summary.txt”.
3. The output should also conclude with a total of the number of files and total file size for each file extension.

Here is as far as I can get:
dir -recurse  -include *.docx, *.xlsx c: | select-object Length, name | sort-Object extension
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

$Search = "C:\"
$Outfile = "C:\Temp\report.csv"
$Files = Dir $Search -recurse  -include  *.doc,*.docx,*.xls,*.xlsx -EA SilentlyContinue | 
	select-object Length,name,Fullname,extension | sort-Object extension

$Files | Export-Csv $Outfile -NoTypeInformation

$Files | Group extension -NoElement | % {$Ext = $_.Name;$_ | Select @{N="Extension";E={$_.Name}},Count,`
		@{N="SizeMB";E={"{0:N2}" -f (($Files | ?{$_.extension -eq $Ext} | Measure Length -Sum).Sum /1MB)}}} | 
		ConvertTo-Csv -NoTypeInformation | Out-File $Outfile -Append -Encoding ASCII

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
sflbuzzmanAuthor Commented:
Thanks Subsun. Way more than I anticipated in the setup ... but, just goes to show how much that I have to learn.

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows Server 2008

From novice to tech pro — start learning today.