D
D
Digsecman2021-08-05 10:28:00
PowerShell
Digsecman, 2021-08-05 10:28:00

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

2 answer(s)
R
Roman Bezrukov, 2021-08-05
@Digsecman

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

A list of users can be obtained in a similar way using Get-ADUser

A
Alexey Dmitriev, 2021-08-05
@SignFinder

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 question

Ask a Question

731 491 924 answers to any question