The next script for today enumerates all hidden distribution groups.
This is done by an ADO query with a filter on groups, msExchHideFromAddressLists and mail property.
Follow the next steps to run the script (no admin rights needed):
- copy and paste the script in your favorite text editor
- save the script (for example c:\temp\hidden-distribution-groups.vbs)
- open a command prompt
- go to “c:\temp”
- give “cscript hidden-distribution-groups.vbs” (without quotes) and enter
The script:
' Name : hidden-distribution-groups.vbs
' Description : script to enumerate all distribution groups that are hidden in the Global Address List
' Author : dirk adamsky - deludi bv
' Version : 1.00
' Date : 15-07-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=group)(msExchHideFromAddressLists=TRUE)(mail=*))"
strAttributes = "displayname, mail, msExchHideFromAddressLists"
strQuery = strBase & ";" & strFilter & ";" & strAttributes & ";subtree"
adoCommand.CommandText = strQuery
adoCommand.Properties("Page Size") = 100
adoCommand.Properties("Timeout") = 30
adoCommand.Properties("Cache Results") = False
Set objRecordset = adoCommand.Execute
objRecordSet.MoveFirst
Do Until objRecordSet.EOF
Wscript.Echo objRecordSet.Fields("displayname").Value & " ; " & objRecordSet.Fields("mail").Value
objRecordSet.MoveNext
Loop
Set objRecordset = Nothing
Set objRootDSE = Nothing
Set adoConnection = Nothing
Set adoCommand = Nothing
When you have problems/questions please post a reply or give a ‘star’ rating.
Happy scripting.
Best regards,
Dirk Adamsky – Deludi BV
VN:F [1.9.3_1094]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.3_1094]
Like this Post? Consider sharing it on one of these:
The script for today is created for Paul.
It is an extension of the previous server uptime script.
The uptime is now formatted in: xx days, xx hours, xx minutes.
Follow the next steps to run the script (admin rights needed for the WMI connections):
- copy and paste the script in your favorite text editor
- save the script (for example c:\temp\serveruptimev2.vbs)
- open a command prompt
- go to “c:\temp”
- give “cscript serveruptimev2.vbs” (without quotes) and enter
The script:
' Name : serveruptimev2.vbs
' Description : script to enumerate the system uptime of all servers in Active Directory V2
' Author : dirk adamsky - deludi bv
' Version : 2.00
' Date : 15-07-2010
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")
strDNSDomain = objRootDSE.Get("defaultNamingContext")
strBase = "<LDAP://" & strDNSDomain & ">"
strFilter = "(&(objectCategory=computer)(operatingSystem=*server*))"
strAttributes = "name"
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
On Error Resume Next
strHostname = adoRecordset.Fields("name").Value
If CheckStatus(strHostname) = False Then
Wscript.Echo strHostname & " does not reply"
Else
Wscript.Echo strHostname & " is up for " & GetUptime(strHostname)
End If
adoRecordset.MoveNext
Loop
adoRecordset.Close
adoConnection.Close
Set adoRecordset = Nothing
Set objRootDSE = Nothing
Set adoConnection = Nothing
Set adoCommand = Nothing
Function CheckStatus(strAddress)
Dim objPing, objRetStatus
Set objPing = GetObject("winmgmts:{impersonationLevel=impersonate}").ExecQuery _
("select * from Win32_PingStatus where address = '" & strAddress & "'")
For Each objRetStatus In objPing
If IsNull(objRetStatus.StatusCode) Or objRetStatus.StatusCode <> 0 Then
CheckStatus = False
Else
CheckStatus = True
End If
Next
Set objPing = Nothing
End Function
Function GetUptime(strServer)
Set objDateTime = CreateObject("WbemScripting.SWbemDateTime")
Set objWMIService = GetObject("winmgmts:\\" & strServer & "\root\cimv2")
Set colOperatingSystems = objWMIService.ExecQuery("Select * from Win32_OperatingSystem")
For Each objOS in colOperatingSystems
objDateTime.Value = objOS.LastBootUpTime
strMinutes = DateDiff("n", objDateTime.GetVarDate, Now)
If strMinutes =< 0 Then
strUptime = "0 days, 0 hours, 0 minutes"
Else
strUptime = ""
If strMinutes >= 1440 Then
strUptime = Round(strMinutes\1440,0) & " days,"
End If
strMinutes = strMinutes Mod 1440
If strMinutes >= 60 Then
strUptime = strUptime & (strMinutes\60) & " hours,"
End If
strMinutes = strMinutes Mod 60
GetUptime = strUptime & strMinutes & " minutes"
End If
Next
Set colOperatingSystems = Nothing
Set objWMIService = Nothing
Set objDateTime = Nothing
End Function
When you have problems/questions please post a reply or give a ‘star’ rating.
Happy scripting.
Best regards,
Dirk Adamsky – Deludi BV
VN:F [1.9.3_1094]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.3_1094]
Like this Post? Consider sharing it on one of these:
I have added an RSS button (orange with white curves) below each post…..
VN:F [1.9.3_1094]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.3_1094]
Like this Post? Consider sharing it on one of these:

The Museumplein several hours before the finals…..

Another museumplein pic….

Some chicks with hairy legs……….
Best regards,
Dirk Adamsky – Deludi BV
VN:F [1.9.3_1094]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.3_1094]
Like this Post? Consider sharing it on one of these:
I have tested Evolution on Windows a couple of years ago.
(ported by Tor Lillqvist).
Found out this morning that mapi support for the Evolution mail client is on the way.
More details can be found here.
Happy scripting.
Best regards,
Dirk Adamsky
VN:F [1.9.3_1094]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.3_1094]
Like this Post? Consider sharing it on one of these:
This script enumerates the local users of all servers (domain controllers are excluded) in your domain.
The results are logged in a file and send with CDO mail.
You can also schedule the script for monitoring purposes.
Follow the next steps to run the script (admin rights needed):
- copy and paste the script in your favorite text editor
- change the smtp addresses of the sender and the recipient to your addresses
- save the script (for example c:\temp\localusers.vbs)
- open a command prompt
- go to “c:\temp”
- give “cscript localusers.vbs” (without quotes) and enter
The script:
' Name : localusers.vbs
' Description : script to enumerate the local users of all servers in your domain
' Author : dirk adamsky - deludi bv
' Version : 1.00
' Date : 10-06-2010
' Level: intermediate
strDate = Replace(Date,"/","-")
Set objFSO = CreateObject("Scripting.FileSystemObject")
strCurrentDir = objFSO.GetAbsolutePathName(".")
Set objFSO = Nothing
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")
strDNSDomain = objRootDSE.Get("defaultNamingContext")
strBase = "<LDAP://" & strDNSDomain & ">"
strFilter = "(&(objectCategory=computer)(operatingSystem=*server*))"
strAttributes = "name,distinguishedName"
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
strHostname = adoRecordset.Fields("name").Value
If CheckStatus(strHostname) = True Then
If Instr(adoRecordset.Fields("distinguishedName").Value,"Domain Controllers") = 0 Then
Set objGroup = GetObject("WinNT://" & strHostname & "/Users,group")
For Each Member In objGroup.Members
If Lcase(Member.Name) <> "interactive" And Lcase(Member.Name) <> "authenticated users" Then
Logprint strHostname & " has " & Member.Name & " in the local users group"
End If
Next
Set objGroup = Nothing
End If
End If
adoRecordset.MoveNext
Loop
Sendmail "recipient@test.org", "localusers", "see attachment for details", strCurrentDir & "\" & strDate & "-localusers.csv"
Set adoRecordset = Nothing
Set objRootDSE = Nothing
Set adoConnection = Nothing
Set adoCommand = Nothing
Function CheckStatus(strAddress)
Dim objPing, objRetStatus
Set objPing = GetObject("winmgmts:{impersonationLevel=impersonate}").ExecQuery _
("select * from Win32_PingStatus where address = '" & strAddress & "'")
For Each objRetStatus In objPing
If IsNull(objRetStatus.StatusCode) Or objRetStatus.StatusCode <> 0 Then
CheckStatus = False
Else
CheckStatus = True
End If
Next
Set objPing = Nothing
End Function
Function LogPrint(Message)
Const ForAppending = 8
Set ObjFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = ObjFSO.OpenTextFile(strDate & "-localusers.csv", ForAppending, True)
objTextFile.WriteLine Message
objTextFile.Close
Set objTextFile = Nothing
Set ObjFSO = Nothing
End Function
Function SendMail(strRecipient, strHeader, strBody, strAttachment)
Set objMessage = CreateObject("CDO.Message")
objMessage.Subject = strHeader
objMessage.From = "sender@test.org"
objMessage.To = strRecipient
objMessage.TextBody = strBody
objMessage.AddAttachment strAttachment
objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "mail.domstad.org"
objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
objMessage.Configuration.Fields.Update
objMessage.Send
Set objMessage = Nothing
End Function
When you have problems/questions please post a reply or give a ‘star’ rating.
Happy scripting.
Best regards,
Dirk Adamsky – Deludi BV
VN:F [1.9.3_1094]
Rating: 10.0/10 (1 vote cast)
VN:F [1.9.3_1094]
Like this Post? Consider sharing it on one of these:
Found out today that Julien Kerihuel and his team have a working preview of openchange server.
Can’t wait to do some CDO scripting against the openchange server……
VN:F [1.9.3_1094]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.3_1094]
Like this Post? Consider sharing it on one of these:
Today I made a script as requested by Jamal.
It is a further development of a script to enumerate all exchange mailboxes and their size which can be found here.
What the script does:
- ask for the smtp address of the mailbox
- get the displayname and homembd properties of that mailbox
- enumerate all exchange servers
- make a wmi connection with the exchange server on which the mailbox resides
- get the size of the mailbox
The script is tested in an win2003/exchange2003 environment.
Follow the next steps to run the script (admin rights needed):
- copy and paste the script in your favorite text editor
- save the script (for example c:\temp\mailboxsize.vbs)
- open a command prompt
- go to “c:\temp”
- give “cscript mailboxsize.vbs” (without quotes) and enter
The script:
' Name : mailboxsize.vbs
' Description : script to show the size of a specific mailbox
' Author : dirk adamsky - deludi bv
' Version : 1.00
' Date : 18-05-2010
' Level: advanced
Dim strDisplayName, strHomeMDB
strSMTP = InputBox("Please fill in the SMTP address of the user")
GetDisplayNameAndHomeMDB(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("configurationnamingcontext") & ">"
strFilter = "(objectCategory=msExchExchangeServer)"
strAttributes = "name"
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
If Instr(strHomeMDB,adoRecordset.Fields("name").Value) > 1 Then
Set objWMIExchange = GetObject("winmgmts:{impersonationLevel=impersonate}!//"&_
adoRecordset.Fields("name").Value & "/root/MicrosoftExchangeV2")
Set colExchangeMailboxes = objWMIExchange.ExecQuery("Select * From Exchange_Mailbox Where MailboxDisplayName = '" & strDisplayName & "'")
For Each objExchangeMailbox in colExchangeMailboxes
If Left(objExchangeMailbox.StorageGroupName, 5) <> "Recov" Then
Wscript.Echo adoRecordset.Fields("name").Value & " ; " & objExchangeMailbox.MailboxDisplayName & " ; " &_
Round(objExchangeMailbox.Size/1024,0) & " MB"
End If
Next
Set colExchange_Mailboxes = Nothing
Set objWMIExchange = Nothing
End If
adoRecordset.MoveNext
Loop
adoRecordset.Close
adoConnection.Close
Set adoRecordset = Nothing
Set objRootDSE = Nothing
Set adoConnection = Nothing
Set adoCommand = Nothing
Function GetDisplayNameAndHomeMDB(strMail)
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")
strDNSDomain = objRootDSE.Get("defaultNamingContext")
strBase = "<LDAP://" & strDNSDomain & ">"
strFilter = "(&(objectCategory=person)(objectClass=user)(mail=" & strMail & "))"
strAttributes = "displayName,homeMDB"
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
strDisplayName = adoRecordset.Fields("displayName").Value
strHomeMDB = adoRecordset.Fields("homeMDB").Value
adoRecordset.Close
adoConnection.Close
Set adoRecordset = Nothing
Set objRootDSE = Nothing
Set adoConnection = Nothing
Set adoCommand = Nothing
End Function
When you have problems/questions please post a reply or give a ‘star’ rating.
Happy scripting.
Best regards,
Dirk Adamsky – Deludi BV
VN:F [1.9.3_1094]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.3_1094]
Like this Post? Consider sharing it on one of these:
Recent Comments