Help with Exchange address book
I am adding a IP phone field to the address book and I found a script to pull the information from AD to the address book. What I have read about the script is that it will only do about 200 users but, I need around 1300 users and I will not do it when adding
a new user I will have to run it reach time. What I need help with is adding more users and having this run all the time so when a new user is added the information is add by default.
Here is the script.
# Script to copy the IpPhone attribute the extensionAttribute1 attribute
# Written by Ben Lye - 07 December 2009
# Find the users in AD using an ADSI search method
$searcher = new-object DirectoryServices.DirectorySearcher([ADSI]"")
# Filter for enabled user accounts with a value in the IpPhone attribute
$searcher.filter = "(&(IpPhone=*)(objectCategory=person)(!(useraccountcontrol:1.2.840.113556.1.4.803:=2)))"
# Return the sorted results
$objects = $searcher.findall() | Sort-Object -Property cn
# Loop through all the objects that the search returned
ForEach ($object in $objects) {
# Store some attribute values into variables
$ipphone = $object.properties.ipphone
$extensionattribute1 = $object.properties.extensionattribute1
$dn = $object.properties.distinguishedname
$adspath = $object.properties.adspath
# If IpPhone is not equal to extensionAttribute1 then process this object
If ($ipphone -ne $extensionattribute1) {
# Get the ADSI object
$adsiobject = [ADSI]"$adspath"
# Set the attribute
$adsiobject.extensionattribute1 = $ipphone
# Commit the changes
$adsiobject.SetInfo()
# Output what just changed
Write-Host $dn ":" $extensionAttribute1 "-->" $IpPhone
}
}
June 4th, 2012 2:54pm
Hi,
if using Windows 2008 the default search size is set to 1000.
In order to increase the max result size set the pagesize parameter to 1
In the above scrict insert the command
$searcher.pagesize = 1
regards Thomas Paetzold visit my blog on: http://sus42.wordpress.com
Free Windows Admin Tool Kit Click here and download it now
June 4th, 2012 3:23pm
Hi,
if using Windows 2008 the default search size is set to 1000.
In order to increase the max result size set the pagesize parameter to 1
In the above scrict insert the command
$searcher.pagesize = 1
regards Thomas Paetzold visit my blog on: http://sus42.wordpress.com
June 4th, 2012 3:32pm
On Mon, 4 Jun 2012 19:23:01 +0000, Peddy1st wrote:
>
>
>Hi,
>
>if using Windows 2008 the default search size is set to 1000.
>
>In order to increase the max result size set the pagesize parameter to 1
>
>In the above scrict insert the command $searcher.pagesize = 1
I think setting it to some larger number would be more efficient. Why
make repeated calls to the AD to retrieve just one search result?
1000 would be safe. 100 is acceptable. Even 10 is better than 1. :-)
---
Rich Matheisen
MCSE+I, Exchange MVP
--- Rich Matheisen MCSE+I, Exchange MVP
Free Windows Admin Tool Kit Click here and download it now
June 4th, 2012 10:33pm
On Mon, 4 Jun 2012 19:23:01 +0000, Peddy1st wrote:
>
>
>Hi,
>
>if using Windows 2008 the default search size is set to 1000.
>
>In order to increase the max result size set the pagesize parameter to 1
>
>In the above scrict insert the command $searcher.pagesize = 1
I think setting it to some larger number would be more efficient. Why
make repeated calls to the AD to retrieve just one search result?
1000 would be safe. 100 is acceptable. Even 10 is better than 1. :-)
---
Rich Matheisen
MCSE+I, Exchange MVP
--- Rich Matheisen MCSE+I, Exchange MVP
June 4th, 2012 10:42pm
Hi Rich,
try it. The documented parameter sizelimit does not work. The documentation says the the valid value range for pagesize is 0 to 1000 But even if <ou use "1" all results for the Ldap Search will be returned.
This information is for using Powershell only. It maybe possible that using vbscript or other languages it will work in a diffrent way.
regards Thomas Paetzold visit my blog on: http://sus42.wordpress.com
Free Windows Admin Tool Kit Click here and download it now
June 5th, 2012 1:27am
On Tue, 5 Jun 2012 05:17:54 +0000, Peddy1st wrote:
>try it. The documented parameter sizelimit does not work. The documentation says the the valid value range for pagesize is 0 to 1000 But even if <ou use "1" all results for the Ldap Search will be returned.
If you're using "pagesize" then "sizelimit" must be set to zero. But
you recommended using "pagesize", not "sizelimit" so I'm not sure why
you're mentioning "sizelimit" now.
If, for example, you have a directory of 100,000 objects and you don't
set either pagesize or sizelimit then you'll only get back as many
results as the AD is configured to return in one page (typically 1,000
or 1,500) no matter how many objects match the search criteria.
If you set sizelimit to somethng smaller than that AD limit of 1,000
or 1,500 you won't get back more than "sizelimit" results no matter
how many objects match the search criteria (and they'll all be
returned in one search page).
If you use pagesize and set it to a value not larger than the AD limit
(using 1,000 is a safe value unless the AD has been restricted to
something smaller) you get back all the objects that match the search
criteria in batches not larger than the pagesize value.
>This information is for using Powershell only. It maybe possible that using vbscript or other languages it will work in a diffrent way.
It's worked the right way in Perl, VBS, and Powershell for me. The
values aren't language specific.
---
Rich Matheisen
MCSE+I, Exchange MVP
--- Rich Matheisen MCSE+I, Exchange MVP
June 5th, 2012 8:51pm
Hi Rich,
this is what it should be concernng the documentation. But I think it works diffrent. Dont use sizelimit only pagesize and set this property to the value of 1. Leave the vaue for sizelimit to its default value. In this case you will get all matching objects
regardless of the amount of data.
regards Thomas Paetzold visit my blog on: http://sus42.wordpress.com
Free Windows Admin Tool Kit Click here and download it now
June 5th, 2012 10:14pm
Instead of 1 I had to use 3000. Thanks for your help.
June 6th, 2012 9:19am
On Wed, 6 Jun 2012 02:05:04 +0000, Peddy1st wrote:
>this is what it should be concernng the documentation. But I think it works diffrent. Dont use sizelimit only pagesize and set this property to the value of 1. Leave the vaue for sizelimit to its default value. In this case you will get all matching
objects regardless of the amount of data.
Yes, you will, but only one object at a time from the AD. Set the
pagesize to a value that makes sense (depending on how large the AD
is, how long the query takes, how many results you expect, and how
long you want to wait for the results).
---
Rich Matheisen
MCSE+I, Exchange MVP
--- Rich Matheisen MCSE+I, Exchange MVP
Free Windows Admin Tool Kit Click here and download it now
June 6th, 2012 2:11pm