This script enables oma (outlook mobile access) based on a list of smtp addresses in an excel sheet.

What the script does:

  • get the users smtp address from the excel sheet (c:\temp\oma.xls)
  • the function FindDN finds the corresponding distinguished name of the user object
  • the function EnableOma enables oma for the user
  • the function LogPrint creates logging for all actions

Follow the next steps to run the script (admin rights needed):

  • create an excel sheet with a list of smtp addresses to be oma enabled
  • save the sheet as c:\temp\oma.xls
  • copy and paste the script in your favorite text editor
  • save the script (for example c:\temp\enableoma.vbs)
  • open a command prompt
  • go to “c:\temp”
  • give “cscript enableoma.vbs” (without quotes) and enter

The script:

' Name : enableoma.vbs
' Description : script to enable oma (outlook mobile access) from an excel sheet
' Author : dirk adamsky - deludi bv
' Version : 1.00
' Date : 06-04-2010

Set objExcel = CreateObject("Excel.Application")
Set objWorkbook = objExcel.Workbooks.Open("C:\temp\oma.xls")
intRow = 2
Do Until objExcel.Cells(intRow,1).Value = ""
    strSmtpAddress = objExcel.Cells(intRow, 1).Value
    If strSmtpAddress <> "" Then
		strDN = FindDN strSmtpAddress
		EnableOma strDN
		Logprint "outlook mobile access is enabled for ; " & strSmtpAddress
	End If
	intRow = intRow + 1
Loop
objExcel.Quit
Set objWorkbook = Nothing
Set objExcel = Nothing

Function EnableOma(strAccount)
	Set objUser = GetObject ("LDAP://" & strAccount)
	objUser.Put "msExchOmaAdminWirelessEnable", "0"
	objUser.setinfo
	Set objUser = Nothing
End Function

Function LogPrint(Message)
Const ForAppending = 8
strDate = Replace(Date,"/","-")
Set ObjFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = ObjFSO.OpenTextFile(strDate & "-OmaEnabledAgain.csv", ForAppending, True)
    objTextFile.WriteLine Message
    objTextFile.Close
Set objTextFile = Nothing
Set ObjFSO = Nothing
End Function

Function FindDN(strSmtp)

	Set adoCommand = CreateObject("ADODB.Command")
	Set adoConnection = CreateObject("ADODB.Connection")
	adoConnection.Provider = "ADsDSOObject"
	adoConnection.Open "Active Directory Provider"
	adoCommand.ActiveConnection = adoConnection

	Set objRootDSE = GetObject("LDAP://RootDSE")
	strBase = "<LDAP://" & objRootDSE.Get("defaultNamingContext") & ">"

	' Filter on user objects.
	strFilter = "(mail=" & strSmtp & ")"

	' Comma delimited list of attribute values to retrieve.
	strAttributes = "distinguishedName"

	' Construct the LDAP syntax query.
	strQuery = strBase & ";" & strFilter & ";" & strAttributes & ";subtree"
	adoCommand.CommandText = strQuery
	adoCommand.Properties("Page Size") = 100
	adoCommand.Properties("Timeout") = 30
	adoCommand.Properties("Cache Results") = False

	' Run the query.
	Set adoRecordset = adoCommand.Execute
	FindDN = adoRecordset.Fields("distinguishedName").Value

	' Clean up.
	adoRecordset.Close
	adoConnection.Close

	Set objRootDSE = Nothing
	Set adoConnection = Nothing
	Set adoCommand = Nothing
End Function

When you have problems/questions please post a reply, you can also rate the script.

Happy scripting.

Best regards,

Dirk Adamsky – Deludi BV

VN:F [1.9.4_1102]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.4_1102]
Rating: 0 (from 0 votes)

This script disables outlook mobile access for all users in your company, this can be useful when oma access has to be restricted to a certain amount of users. Later I will post a script to enable oma for a limited amount of users based on an excel sheet with smtp addresses.
The script is created for a win2003/exchange2003 environment.

Follow the next steps to run the script (admin rights needed):

* open your favorite text editor
* copy and paste the script into the editor
* save the script (for example c:\temp\disableoma.vbs)
* open a command prompt
* go to “c:\temp”
* give “cscript disableoma.vbs” (without quotes) and enter

The script:

' Name : disableoma.vbs
' Description : script to disable Outlook Mobile Access (oma) for all users in your company
' Author : dirk adamsky - deludi bv
' Version : 1.00
' Date : 31-03-2010
' Level : intermediate

Set adoCommand = CreateObject("ADODB.Command")
Set adoConnection = CreateObject("ADODB.Connection")
adoConnection.Provider = "ADsDSOObject"
adoConnection.Open "Active Directory Provider"
adoCommand.ActiveConnection = adoConnection

Set objRootDSE = GetObject("LDAP://RootDSE")
strBase = "<LDAP://" & objRootDSE.Get("defaultNamingContext") & ">"
strFilter = "(&(objectCategory=person)(objectClass=user)(mail=*)(!(msExchOmaAdminWirelessEnable=7)))"
strAttributes = "mail,msExchOmaAdminWirelessEnable"

strQuery = strBase & ";" & strFilter & ";" & strAttributes & ";subtree"
adoCommand.CommandText = strQuery
adoCommand.Properties("Page Size") = 100
adoCommand.Properties("Timeout") = 30
adoCommand.Properties("Cache Results") = False

Set adoRecordset = adoCommand.Execute

Do Until adoRecordset.EOF
	Set objUser = GetObject ("LDAP://" & adoRecordset.Fields("distinguishedName").Value)
	objUser.Put "msExchOmaAdminWirelessEnable", "7"
    objUser.Setinfo
	Set objUser = Nothing
	Logprint "outlook mobile access is disabled for ; " & adoRecordset.Fields("mail").Value
	adoRecordset.MoveNext
Loop

adoRecordset.Close
adoConnection.Close

Set adoRecordset = Nothing
Set objRootDSE = Nothing
Set adoConnection = Nothing
Set adoCommand = Nothing

Function LogPrint(Message)
Const ForAppending = 8
strDate = Replace(Date,"/","-")

Set ObjFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = ObjFSO.OpenTextFile(strDate & "-OmaDisabledUsers.csv", ForAppending, True)
    objTextFile.WriteLine Message
    objTextFile.Close
Set objTextFile = Nothing
Set ObjFSO = Nothing
End Function

When you have problems/questions please post a reply, you can also rate the script.

Happy scripting.

Best regards,

Dirk Adamsky – Deludi BV

VN:F [1.9.4_1102]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.4_1102]
Rating: 0 (from 0 votes)

Outlook mobile access (oma) is enabled by default in Active Directory.
In large organizations this feature is often disabled by the systems administrators.
This script enumerates the status of oma for all active directory accounts.
The output is logged in a file called date-omausers.csv.
It is tested for outlook/exchange2003.

Follow the next steps to run the script (no admin rights needed):

* open your favorite text editor
* copy and paste the script into the editor
* save the script (for example c:\temp\omausers.vbs)
* open a command prompt
* go to “c:\temp”
* give “cscript omausers.vbs” (without quotes) and enter

The script:

' Name : omausers.vbs
' Description : script to enumerate all users with Outlook Mobile Access (oma)
' Author : dirk adamsky - deludi bv
' Version : 1.00
' Date : 31-03-2010
' Level : intermediate

Set adoCommand = CreateObject("ADODB.Command")
Set adoConnection = CreateObject("ADODB.Connection")
adoConnection.Provider = "ADsDSOObject"
adoConnection.Open "Active Directory Provider"
adoCommand.ActiveConnection = adoConnection

Set objRootDSE = GetObject("LDAP://RootDSE")
strBase = "<LDAP://" & objRootDSE.Get("defaultNamingContext") & ">"
strFilter = "(&(objectCategory=person)(objectClass=user)(mail=*))"
strAttributes = "mail,msExchOmaAdminWirelessEnable"

strQuery = strBase & ";" & strFilter & ";" & strAttributes & ";subtree"
adoCommand.CommandText = strQuery
adoCommand.Properties("Page Size") = 100
adoCommand.Properties("Timeout") = 30
adoCommand.Properties("Cache Results") = False

Set adoRecordset = adoCommand.Execute

Do Until adoRecordset.EOF
	strOma = "Yes"
	If adoRecordset.Fields("msExchOmaAdminWirelessEnable").Value = 7 Then
		strOma = "No"
	End If
	Logprint adoRecordset.Fields("mail").Value & ":" & strOma
	adoRecordset.MoveNext
Loop

adoRecordset.Close
adoConnection.Close

Set adoRecordset = Nothing
Set objRootDSE = Nothing
Set adoConnection = Nothing
Set adoCommand = Nothing

Function LogPrint(Message)
Const ForAppending = 8
strDate = Replace(Date,"/","-")
Set ObjFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = ObjFSO.OpenTextFile(strDate & "-OmaUsers.csv", ForAppending, True)
    objTextFile.WriteLine Message
    objTextFile.Close
Set objTextFile = Nothing
Set ObjFSO = Nothing
End Function

When you have problems/questions please post a reply, you can also rate the script.

Happy scripting.

Best regards,

Dirk Adamsky – Deludi BV

VN:F [1.9.4_1102]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.4_1102]
Rating: 0 (from 0 votes)
© 2010 Dirk Adamsky Scripting Blog Suffusion WordPress theme by Sayontan Sinha