Link to home
Start Free TrialLog in
Avatar of naifyboy123
naifyboy123Flag for Afghanistan

asked on

VB Script Help with AD

Please can you help?
I got the following script from Microsoft. It is supposed to disable to OMA for accoutns in AD.

=================================================
On Error Resume Next
Set objRootDSE = GetObject("LDAP://rootDSE")
Set objUsers = GetObject("LDAP://CN=Users, " & objRootDSE.Get("defaultNamingContext"))
' set msExchOmaAdminWirelessEnable to 7 if currently null
For Each objUser In objUsers
            strname = objUser.Get("name")
'            WScript.Echo "name: " & strname
            strWirelessEnabled = objUser.Get("msExchOmaAdminWirelessEnable")
            If strWirelessEnabled = "" Then
                        objUser.Put "msExchOmaAdminWirelessEnable", "7"
                        objUser.setinfo
            End If
            strWirelessEnabled = objUser.Get("msExchOmaAdminWirelessEnable")          
Next
WScript.Echo "Mobile Services disabled for all users"
===========================================================

The OU where the accounts reside in my AD is:

Enter.local,   Users, London  (ou=London, ou=users, dc=Enter, dc=local)

When I run the script nothing changes. Maybe I havent entered the LDAP path correctly in the query? I noticed in the example from Microsoft that they entered the Users OU as CN=Users and I have also tried to change my script as such and still it doesn't work.

I have edited the script as below:

==================================================
On Error Resume Next
Set objRootDSE = GetObject("LDAP://rootDSE")
Set objUsers = GetObject("LDAP://OU=London,OU=Users,DC=Enter,DC=local, " & objRootDSE.Get("defaultNamingContext"))
' set msExchOmaAdminWirelessEnable to 7 if currently null
For Each objUser In objUsers
            strname = objUser.Get("name")
'            WScript.Echo "name: " & strname
            strWirelessEnabled = objUser.Get("msExchOmaAdminWirelessEnable")
            If strWirelessEnabled = "" Then
                        objUser.Put "msExchOmaAdminWirelessEnable", "7"
                        objUser.setinfo
            End If
            strWirelessEnabled = objUser.Get("msExchOmaAdminWirelessEnable")          
Next
WScript.Echo "Mobile Services disabled for all users"

Based on the location of the OU, please can someone help me get this script working.

Thanks in advance.



ASKER CERTIFIED SOLUTION
Avatar of RobSampson
RobSampson
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks for the grade.  I hope I was clear.  Do my comments make sense?

Regards,

Rob.
Avatar of naifyboy123

ASKER

yes they do thanks