This topic contains 4 replies, has 3 voices, and was last updated by
October 8, 2013 at 8:07 am #10602
Hi, I'm very new to powershell. I'm running ps from a windows 7 computer connecting to a domain controller running Windows 2008 sp2 (not r2) over active directory web services.
I'm running a get-adcomputer script and piping that to another powershell function and exporting the results to a csv file on my windows 7 computer.
The script works fine until it reaches 16kb of data results, every time. Any idea what is causing that and how to fix it?
We do not have an r2 domain controller so I cannot run import-module activedirectory on a win2008 sp2 server.
October 8, 2013 at 8:08 am #10603
This is the error when it disconnects.
get-adcomputer : Unable to contact the server. This may be because this server does not exist, it is currently down, or it does not have the Active Directory Web
October 8, 2013 at 8:30 am #10604KeymasterTopics: 13Replies: 4872Points: 1,811Rank: Community Hero
(in the future, you'll want to avoid replying to your own message – a lot of us look for "posts with no replies," and when you reply, you take yourself off that list, so we miss your question!!)
The AD commands do have some limits on the amount of data they'll retrieve by default. That's done to protect performance on the DC, and is actually a standard DC behavior no matter how you're retrieving data. The Get-ADComputer cmdlet should have some additional information on that, and I bet our resident AD cmdlet expert will also check in here and offer some advice. He's in the UK, so it may be a bit before he sees your message.
I'm assuming you got Get-ADComputer from the Windows 7 RSAT. You MUST have one DC running the free AD Management Gateway add-in – that's the the cmdlets talk to. It runs fine on Win2008 (non-R2), but you have to specifically download and install it. Win2008R2 comes with the add-in, but it can be added to older DCs back to Win2003.
October 8, 2013 at 11:03 am #10616
Thanks for the tip, Don. You actually helped me figure it out. Get-help get-adcomputer shows -ResultPageSize and -ResultSetSize parameters. Setting this fixed the problem.
October 8, 2013 at 12:39 pm #10617ParticipantTopics: 0Replies: 669Points: 0Rank: Member
By default AD has a limit of 1000 objects that it will return. I suspect if you look at you 16kb file it will contain 1000 objects (maybe slightly less). The limit is in place to avoid querying a very large AD and stressing the DC because you pull too much back. As you've discovered -ResultSetSize will solve your problem. This is a common issue & one I still trip over as my lab a AD only has about 900 objects.
The most important lesson from this is that the help files are your friend.
The topic ‘Powershell data limit?’ is closed to new replies.