PowerShell Genie
Practice List Finance team accounts

List Finance team accounts

Exercise 1 min read Windows PowerShell 5.1 and PowerShell 7

Documentation: Microsoft Learn

Return every account in the Finance department.

The task

Finance is rolling out a new expense tool. List every Finance account so nobody is missed during onboarding.

Target

Return every account in the Finance department.

What the result tells you

One Where-Object on Department narrows the whole directory to a single team before you pick the columns for the report.

Verify the result

Run the source by itself and inspect the sample objects. Add each filter separately, then check the final properties and order.

The browser uses a small fictional dataset. Real results depend on the host, module, account and target environment.

What does Where-Object Department -eq 'Finance' return?

Choose an answer, then check your reasoning.

Worked solution

Worked solution

Reveal one approach
1PS> Get-ADUser -Filter * | Where-Object Department -eq 'Finance' | Select-Object Name, SamAccountName

Related reference

Read the command and platform requirements
Next exercise

Try it in the lab

Write your pipeline below and run it against the fictional sample data, then check your result against the expected answer.

Interactive simulation · fictional data
Genie guideList Finance team accounts

Return every account in the Finance department.