none
ADSI Edit script

    Question

  • 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.


    Thursday, February 16, 2012 7:37 PM

Answers

All replies

  • objGroup.Put "msExchHideFromAddressLists", True

    No quotes on True. It is not a string it is a boolean.


    ¯\_(ツ)_/¯

    Thursday, February 16, 2012 8:01 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", TRUE

    objGroup.SetInfo

    wscript.echo "done"

    Sunday, February 19, 2012 1:05 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")


    ¯\_(ツ)_/¯

    Sunday, February 19, 2012 2:00 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:50 PM
  • You put that lineinto the script.  It is the line that says 'inputbox' .  If you don't want it then remove it.

    What is 'POOH'?


    ¯\_(ツ)_/¯

    Thursday, February 23, 2012 3:59 PM
  • "pooh" his my Domain Controller.
    Sunday, February 26, 2012 8:29 AM
  • 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 1:22 PM
  • Thank you very much, this time its work.

    Sunday, February 26, 2012 3:46 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 12:14 PM
  • 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

    Tuesday, February 28, 2012 2:52 PM
  • 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 9:05 AM
  • 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

    Monday, March 05, 2012 1:20 PM
  • Great, thank you.
    Wednesday, March 07, 2012 6:55 AM