PowerShell Genie
Practice Find enabled IT staff accounts

Find enabled IT staff accounts

Exercise 2 min read Windows PowerShell 5.1 and PowerShell 7

Documentation: Microsoft Learn

Return the enabled accounts in the IT department, with their sign-in names.

The task

The IT manager needs a headcount of active IT staff for a license renewal. List each enabled IT account with its sign-in name.

Target

Return the enabled accounts in the IT department, with their sign-in names.

What the result tells you

Department groups accounts by team, and Enabled tells you whether the account can sign in. Filtering on both keeps the license count honest.

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.

Why filter on Enabled as well as Department?

Choose an answer, then check your reasoning.

Worked solution

Worked solution

Reveal one approach
1PS> Get-ADUser -Filter * | Where-Object Department -eq 'IT' | Where-Object Enabled -eq $true | 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 guideFind enabled IT staff accounts

Return the enabled accounts in the IT department, with their sign-in names.