How to get-adcomputer

Hi Team,

Please advise on how to get-adcomputer objects every 1000 and continue until the end of the count?

and also outpout in csv file. like first 1000 objects will output to csv file then continue again to next 1000 and output in the same csv file.

i dont know on how to proceed to construct the script.



Get-ADUser doesn’t support paging as far as I’m aware. You can specify that the web service pages 1000 records at a time using -ResultPageSize, but it will still return all records based on -ResultSetSize param. Why do you want to get AD records in this manner? I’ve gotten 50000 AD records in a couple of min, so what is the use case for this?

Hi rob.

Thanks for your question.

Basicaly .when i execute the get-adcomputer and filter the operating system its getting halt or hang.

And sometimes its showing server is down or not exist.

And im querying 700 000 computet objects.

I just want to query every 1000 objects until to reach the last count.and i dont how to achieve.


Hope you can help me with my issue on how to consttuct the script



Well, 700k records is a lot of computer objects. Are you using a filter to only return what you need?‑adcomputer/

There are timeouts, typically 2 minutes to get results in a recordset:

Boy howdy, that is a LOT of computers.

Hi tony.

Yes its very huge computer objects.and that is the peoblem. And my plan is to get every 1000 objects.i just dont know on how to achieve

Hi rob.

Ill check on the links.thanks

Well, I did a query using:

Get-ADComputer -Filter 'OperatingSystem -like "windows"'

Which returned 161K objects.

I also ran

Get-ADComputer -Filter 'OperatingSystem -like "server"'

Which returned 29K objects. Have you tried anything yet? I don’t believe in either case a limit was exhausted, at least I did not get any errors.

Rob points out there is a 2 minute limit to Get-Aduser, assuming that also applies to Get-ADComputer, I ran the following as a test of the time it took

(Measure-Command -Expression{$winSystems = Get-ADComputer -Filter ‘OperatingSystem -like “windows

Which returned 151.2605417 which is 2.5 minutes. So you may be in luck.


Hi rob.

I try the commammd that you provide but error occur.


Server does not exist.i done know why.

Server is reachable and pingable.


Can you get any results from Get-ADComputer? If you search for a specific computer, does it work? You are saying to tried the commands? Which commands? What is working? What specifically is not working? Please provide examples of the code you are trying and the exact error.

Get-ADComputer -server test.domain -Filter ‘OperatingSystem -like “windows”’

That is the command i used.

The result show 5k computer objrcts only then after awhile it was error showing unable to connect.


And i just notice its takes an hour to get the 5k objects.

Maybe you can filter on names starting with ‘a’, then names starting with ‘b’, etc?

Wow - an hour ?? In theory, you should not need to define the server. It should connect to whatever is defined in $ENV:LogonServer. Are you able to RDP to a Domain Controller and try the commands from there?

It seems like you may have underlying network performance issues. How did you determine the 5K count?

With so many, batching it up is probably a good approach. This might help you figure out a good filter, this is getting the info you want starting at a specific organizational unit. From here, you could run it against each of larger containers individually, automate it, or whatever your intent is.

$Things = "Name","OperatingSystem","PasswordLastSet","Enabled","DistinguishedName"
(Get-ADOrganizationalUnit -Filter "DistinguishedName -like '*DC=contoso,DC=com'").DistinguishedName | % {Get-ADComputer -F * -Properties $Things | select $Things | Export-Csv C:\Temp\Stuff.csv -Append -NoClobber}

For my test directory, about 2k objects were returned in a 256k CSV file in less than 2 seconds. I also set the filters to include the operating system. If you wanted to only look for a specific OS, you could do that with something like this before the select-object bits…

| where-object {$_.OperatingSystem -like "Windows Server 2019*"}


Hi tony

I dont have right to rdp the machine.

Or no interactive access to log in.

But im able to query the AD remotely.

Basicaly i query 8 domains controllers

Only one domain with huge computer objects that i having issue and the 7 domain are succesaful to query.

Do you have enough privilege to try Invoke-Command ?

Something like:

Invoke-Command -ComputerName ‘slowserver’ -ScriptBlock {Get-ADComputer -Filter ‘OperatingSystem -like “windows”’}

In theory, this should run on the server in question, although 700K objects is a huge amount. I still think you may have underlying network issues. I would try these commands from a shell on a few servers and compare them to the slow server.

‘ping server’

‘tracert server’

For the first command, make a note of ‘time=xxx’ and compare amongst servers

For the second command, make a note of the number of hops. The more hops, the more latency, the slower things are.

If you have a list of the computers, there’s various ways to run them a piece at a time.

Js i dont nave list of computer.

I just run the command and export to csb file.


What if using adsi ldap.

Is that possible?

Im not yet familiar with ldap adsi

Can you give me on how to start using ldap instead of .net


Did you try using Invoke-Command ???