Answer the question
In order to leave comments, you need to log in
How to display a list of AD users besides the DC itself?
Hello, please tell me how to display a list of all users from a domain controller but not include the domain itself in the list? This line displays all PCs including the domain.
$computers = (Get-ADComputer -Filter * -Property *|Select-Object Name).Name;
Answer the question
In order to leave comments, you need to log in
Do you need a list of users or a list of computers?
List of computers excluding domain controllers:
(Get-ADComputer -LDAPFilter "(&(objectCategory=computer)(!userAccountControl:1.2.840.113556.1.4.803:=8192))" -Properties name | Sort).name
Do you even understand that you are asking for a list of users in the title - and in the body of the question you are discussing computer accounts?
You can filter computer accounts of domain controllers, for example
1. Specify certain OUs in -SearchBase
2. Exclude exclude OU Domain Controllers from search in -filter {DistinguishedName
-notlike "*,OU=SubOU,OU=ParentOU,OU=All Users,DC=domain ,DC=local"}
3. Run the list with -Properties * and filter by Domain Controllers group membership
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question