PowerShell·PowerShell essentials

Small automation

Automate a report that counts files by extension.

Beginner 10 min read Lesson 5 of 150 Challenge included
What you will be able to do
  • Group objects with Group-Object.
  • Sort and format the result.
  • Write the output to a file.

In plain English

Automate a report that counts files by extension.

  • Group objects with Group-Object.
  • Sort and format the result.
  • Write the output to a file.
report.ps1POWERSHELL
Get-ChildItem -File |
  Group-Object Extension |
  Sort-Object Count -Descending |
  Select-Object Name, Count |
  Export-Csv report.csv -NoTypeInformation
Your turn

Explain it back

Easy

Answer from memory: Which cmdlet groups objects by a property?

TEXT · starter
Your answer…
Check your understanding before moving on.
Knowledge checkQuestion 1

Which cmdlet groups objects by a property?

Select an answer to continue
Study tools

Make it yours.

Keep a private note for this lesson, then turn the key ideas into flashcards you can revisit.

Sign in to save notes and flashcards.Both are private to your account and stay with your progress.
Sign in
Finished reading?

Lock in what you just learned.

Mark this lesson complete to save your place and move one step closer to the certificate.

Lesson 5 of 150 · 0% of course