How to show every local users in every local hosts in AD DC environment

Hi guys,

I need to find all local users in all local hosts in AD DC environment, I found a PS guide: How to Get Local Users with or without PowerShell

In that guide I should use a *.txt file where I should store every hosts, is it possible to have something like what I need but without to use a file with all hosts?

This is what I use to have the list of all hosts:

Get-ADComputer -Filter * -Properties * |
    Select -Property Name |
        Export-CSV "C:\AD\Reports\AllComputers.csv" -NoTypeInformation -Encoding UTF8

I should put this feature in to the file who list all local users… :\


First of all - could you plesae not select DSC as the category for your question when it’s not about DSC?

Thanks in advance. :wink:

There shouldn’t be any local users when you have an AD. I’d recommend reviewing your processes or company rules according this topic.

Of course. You can use whatever data source fits your requirement.

Queries like this usually heavily depend on the availability of the local computer you want to query. If you have a sowftware deployment solution in place you could utilize this for this particular purpose.

Regardless of all that

Querying your AD for ALL computers and ALL of their properties puts a lot of stress to the DC you query. Especially when you actually throw away ALL additional properties you just queried except of the name. You should consider using a -SearchBase for your queries and querying only the properties you need. In this case this should be enough:

Get-ADComputer -Filter * |
    Select -Property Name
1 Like

Hi Olaf,

thanks for your prompt reply and sorry for my late answer!

Ok, I got the point I’ll try to use the right area for my questions!

I’ll use a “-SearchBase” like what you said!

Thanks! :slight_smile: