SOLVED: Active Directory PowerShell Get-ADUser returns computer accounts and special accounts as well as normal accounts

By default the Active Directory PowerShell cmdlet Get-ADUser returns special accounts such as trust accounts.

If you only want normal user accounts you need to use the user account control flags which are documented here:

https://learn.microsoft.com/en-us/troubleshoot/windows-server/identity/useraccountcontrol-manipulate-account-properties

Specifically you need the following flag

NORMAL_ACCOUNT

0x0200

512


The easiest way to provide this is to use the filter parameter and the bitwise AND which determines whether flag 512 is set.

Get-ADUser -Filter "userAccountControl -band 512"


 While you're here -
Why not check out our 
Active Directory Documentation Tool?

Comments

Popular posts from this blog

Windows Server 2016, 2019, 2022, Windows 10 and Windows 11: Date and time "Some settings are managed by your organization".

TFTPD32 or TFTPD64 reports Bind error 10013 An attempt was made to access a socket in a way forbidden by its access permissions.

Windows Server 2019 desktop icons such as My Computer, Windows cannot access the specified device, path, or file.