PowerShell Genie
Practice Audit disabled AD accounts

Audit disabled AD accounts

Exercise 1 min read Windows PowerShell 5.1 and PowerShell 7

Documentation: Microsoft Learn

Return the disabled accounts and their sign-in names.

The task

A monthly access review needs a list of disabled accounts. Report the account names without changing their state.

Target

Return the disabled accounts and their sign-in names.

What the result tells you

Enabled describes account state. A disabled account can still retain group membership; this report does not establish that cleanup is complete.

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 keep SamAccountName in the report?

Choose an answer, then check your reasoning.

Worked solution

Worked solution

Reveal one approach
1PS> Get-ADUser -Filter * | Where-Object Enabled -eq $false | 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 guideAudit disabled AD accounts

Return the disabled accounts and their sign-in names.