ADSI Edit script
-
Thursday, February 16, 2012 7:37 PM
Hi, I am experience difficulty to change specific
Attribute “msExchHideFromAddressLists” with vbs script in ADSI Edit.
We are using Server 2003 has DC with Exchange 2007 (BPOS)I want to change this Attribute to all users in specific OU
“External-Contacts”I try couple script from TechNet Forums and other Forums but without success.
Here is one of them:
Const ADS_PROPERTY_UPDATE = 2
cn_string = inputbox("Please enter users CN ex.
cn=username,ou=OU_Names,dc=Domain,dc=Tld")sLDAP = "LDAP://" & cn_string
'Write user properties
Set objGroup = GetObject(sLDAP)
objGroup.Put "msExchHideFromAddressLists","TRUE"
objGroup.SetInfo
wscript.echo "done"
please help me to find
simple script that abele to do the job.it can be VBS/BAT/Power Shale
thanks.
All Replies
-
Thursday, February 16, 2012 8:01 PM
objGroup.Put "msExchHideFromAddressLists", True
No quotes on True. It is not a string it is a boolean.
¯\_(ツ)_/¯
- Proposed As Answer by Richard MuellerMVP, Moderator Saturday, February 18, 2012 7:31 PM
- Marked As Answer by IamMredMicrosoft Employee, Owner Sunday, February 19, 2012 6:29 AM
-
Sunday, February 19, 2012 1:05 PM
Thanks for your answer, but it’s still not working.
I get error about Line: 4 Char: 19
Error : Expected ‘)’
Const ADS_PROPERTY_UPDATE = 2
cn_string = inputbox("Please enter users CN ex. cn=rvbreukelen,ou=External-Contacts,dc=gspaces,dc=com")
sLDAP = ("POOH://"CN=rvbreukelen,OU=External-Contacts,DC=gspaces,DC=com")
'Write user properties
Set objGroup = GetObject("POOH://"CN=rvbreukelen,OU=External-Contacts,DC=gspaces,DC=com")
objGroup.Put "msExchHideFromAddressLists", TRUEobjGroup.SetInfo
wscript.echo "done"
-
Sunday, February 19, 2012 2:00 PM
Set objGroup = GetObject("POOH://"CN=rvbreukelen,OU=External-Contacts,DC=gspaces,DC=com")
Too many quotes in the line - should be:
Set objGroup = GetObject("POOH://CN=rvbreukelen,OU=External-Contacts,DC=gspaces,DC=com")
¯\_(ツ)_/¯
-
Thursday, February 23, 2012 3:50 PM
Hi
Ok I removed the unnecessary quotes, and I get small window that say
Please enter users CN ex.
Cn=rvbreukelen,ouExternal-Contacts,dc-gspaces ( in the bottom I have free line to put something? )
What I need to provide him.
After I click Cancel on this window I get error windows Line: 6 Char: 1 Error: invalid Syntax Code:800401E4
I try to upload sum picture but he doesn’t show them.
Thanks for help.
-
Thursday, February 23, 2012 3:59 PM
-
Sunday, February 26, 2012 8:29 AM"pooh" his my Domain Controller.
-
Sunday, February 26, 2012 1:22 PMModerator
No need to specify the Domain Controller. However, you do need to specify the LDAP moniker. Probably, all you need is the following:
Set objGroup = GetObject("LDAP://"CN=rvbreukelen,OU=External-Contacts,DC=gspaces,DC=com
objGroup.Put "msExchHideFromAddressLists", TRUE
objGroup.SetInfo
wscript.echo "done"
-----
Richard Mueller - MVP Directory Services
-
Sunday, February 26, 2012 3:46 PM
Thank you very much, this time its work.
-
Tuesday, February 28, 2012 12:14 PM
Hi
I want to run this script on OU, so I change him to look like this.
Set objOU =GetObject(LDAP://OU=AdsiTemp,DC=gspaces,DC=com)
objOU.Put "msExchHideFromAddressLists", TRUE
objOU.SetInfo
wscript.echo "done"
I get small window that say done.
But the attribute doesn’t change, can you tell me please how do I run this script on OU
Thanks.
- Edited by Idan_Simhon Tuesday, February 28, 2012 12:48 PM
-
Tuesday, February 28, 2012 2:52 PMModerator
To modify this setting for all users in an OU, enumerate the users in the OU with code similar to below:
' Bind to the OU object.
Set objOU =GetObject(LDAP://OU=AdsiTemp,DC=gspaces,DC=com)
' Filter on user objects.
objOU.filter = Array("user")
' Enumerate all users in the OU.
For Each objUser In objOU
objUser.Put "msExchHideFromAddressLists", TRUE
objUser.SetInfo
End If
wscript.echo "done"
-----
Richard Mueller - MVP Directory Services
-
Monday, March 05, 2012 9:05 AM
Hi,
thanks for your replay.
When I run the script I get Error: Expected ‘)’ Line: 2 Char: 27
So I add quotes between the brackets > (“LDAP://OU=AdsiTemp,DC=gspaces,DC=com”)
And then I get Error: Expected statement Line: 11 Char: 2
I need to right something after End If
Thanks.
-
Monday, March 05, 2012 1:20 PMModerator
Sorry, the script should be as follows:
' Bind to the OU object.
Set objOU =GetObject("LDAP://OU=AdsiTemp,DC=gspaces,DC=com")
' Filter on user objects.
objOU.filter = Array("user")
' Enumerate all users in the OU.
For Each objUser In objOU
objUser.Put "msExchHideFromAddressLists", TRUE
objUser.SetInfo
Next
wscript.echo "done"
-----
Richard Mueller - MVP Directory Services
-
Wednesday, March 07, 2012 6:55 AMGreat, thank you.

