naifyboy123
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("defaultNam ingContext "))
' set msExchOmaAdminWirelessEnab le to 7 if currently null
For Each objUser In objUsers
strname = objUser.Get("name")
' WScript.Echo "name: " & strname
strWirelessEnabled = objUser.Get("msExchOmaAdmi nWirelessE nable")
If strWirelessEnabled = "" Then
objUser.Put "msExchOmaAdminWirelessEna ble", "7"
objUser.setinfo
End If
strWirelessEnabled = objUser.Get("msExchOmaAdmi nWirelessE nable")
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=Londo n,OU=Users ,DC=Enter, DC=local, " & objRootDSE.Get("defaultNam ingContext "))
' set msExchOmaAdminWirelessEnab le to 7 if currently null
For Each objUser In objUsers
strname = objUser.Get("name")
' WScript.Echo "name: " & strname
strWirelessEnabled = objUser.Get("msExchOmaAdmi nWirelessE nable")
If strWirelessEnabled = "" Then
objUser.Put "msExchOmaAdminWirelessEna ble", "7"
objUser.setinfo
End If
strWirelessEnabled = objUser.Get("msExchOmaAdmi nWirelessE nable")
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.
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
' set msExchOmaAdminWirelessEnab
For Each objUser In objUsers
strname = objUser.Get("name")
' WScript.Echo "name: " & strname
strWirelessEnabled = objUser.Get("msExchOmaAdmi
If strWirelessEnabled = "" Then
objUser.Put "msExchOmaAdminWirelessEna
objUser.setinfo
End If
strWirelessEnabled = objUser.Get("msExchOmaAdmi
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=Londo
' set msExchOmaAdminWirelessEnab
For Each objUser In objUsers
strname = objUser.Get("name")
' WScript.Echo "name: " & strname
strWirelessEnabled = objUser.Get("msExchOmaAdmi
If strWirelessEnabled = "" Then
objUser.Put "msExchOmaAdminWirelessEna
objUser.setinfo
End If
strWirelessEnabled = objUser.Get("msExchOmaAdmi
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
yes they do thanks
Regards,
Rob.