?
Solved

Powershell script - LDAP - PageSize Function

Posted on 2014-08-18
3
Medium Priority
?
1,046 Views
Last Modified: 2014-08-23
Hello,

I'm running a script that browse my LDAP. It has worked fine for a long time but yesterday I've been faced to a strange issue.

Some objects were not fetch by the query.
To correct this I was forced to change the PageSize from 1000 to 500.

I don't know why and send a request here if someone could explain me why this pagesize stop to work as requested ?

Thx in advance.
0
Comment
Question by:Sybux
  • 2
3 Comments
 
LVL 29

Expert Comment

by:Dan McFadden
ID: 40269749
A little more info about the script would be helpful.  Are you using the "System.DirectoryServices.DirectorySearcher" class?  If so, are you using the defaults for the properties on the object you created?

Some possibly useful links:

https://groups.google.com/forum/?hl=en#!msg/microsoft.public.adsi.general/b2vv_bSGDvk/xi_h-sPeXGEJ

http://geekswithblogs.net/mnf/archive/2005/12/20/63581.aspx

This blog has a lot of useful examples:  http://www.jaapbrasser.com/

Dan
0
 

Author Comment

by:Sybux
ID: 40269755
woops, sorry I missed the code :)

$query = New-Object System.DirectoryServices.DirectorySearcher($edir)
$query.PageSize = 500
$objClass = $query.findall()

Open in new window


Thx for the link but I've already read them via google but it doesn't help me to understand why with pagesize of 1000 not all records are fetched.
0
 
LVL 29

Accepted Solution

by:
Dan McFadden earned 2000 total points
ID: 40269830
It would appear that you were trying to return more than the server-side limit of objects.  That implies that you directory object count is above 1000.  By lowering the PageSize you allowed the scripting to grab 500 objects (which is less than the default server-side limit of 1000) then to go back and get the next 500, and so on.  Allowing your script to grab more than the server limit.

This is in the MSDN docs at:  http://msdn.microsoft.com/en-us/library/system.directoryservices.directorysearcher.aspx ... check the Remarks near the bottom of the page.

Dan
0

Featured Post

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

After seeing many questions for JRNL_WRAP_ERROR for replication failure, I thought it would be useful to write this article.
Microsoft Office 365 is a subscriptions based service which includes services like Exchange Online and Skype for business Online. These services integrate with Microsoft's online version of Active Directory called Azure Active Directory.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the adminiā€¦
Loops Section Overview

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question