Archive for June, 2009

Exporting 2003 Mailbox Data to CSV

Saturday, June 13th, 2009

I have been using this code for a while and thought I would post it.

I manage several Exchange 2003 servers, this PowerShell code will allow you to pull Mailbox data from each server into their own .CSV file.
It uses a built Array for the server list and parses the Array to get Mailbox data from each server.

$Mailboxes = $Null
$Computers = "Server1","Server2","Server3","Server4"
ForEach($Computer in $Computers)
{
$Mailboxes = Get-WmiObject -NameSpace Root\MicrosoftExchangeV2 -Class Exchange_Mailbox -Computer $Computer
$Mailboxes | Export-Csv "C:\Mailboxes_$Computer.csv" -NoTypeInformation
}

You can combine this with ADSI code to discover all your Exchange 2003 servers in your Directory.
This would give you Mailbox data on all of your Exchange 2003 servers without the need for a manual Array.

[Array]$ExchSrvs = @("")
[String]$StrFilter =(objectCategory=msExchExchangeServer)$objRootDSE = [ADSI]“LDAP://RootDSE”
[String]$strContainer = $objRootDSE.configurationNamingContext
$objSearcher = New-Object System.DirectoryServices.DirectorySearcher
$objSearcher.SearchRoot = New-object System.DirectoryServices.DirectoryEntry(”LDAP://$strContainer)
$objSearcher.PageSize = 1000
$objSearcher.Filter = $strFilter
$objSearcher.SearchScope = “Subtree”
$colServers = $objSearcher.FindAll()
ForEach($objServer in $colServers)
{
[String]$Server = $objResult.Properties.name
$ExchSrvs += $Server
}
$ExchSrvs.Count

Your final script would look something like this.

[Array]$ExchSrvs = @("")
[String]$StrFilter =(objectCategory=msExchExchangeServer)$objRootDSE = [ADSI]“LDAP://RootDSE”
[String]$strContainer = $objRootDSE.configurationNamingContext
$objSearcher = New-Object System.DirectoryServices.DirectorySearcher
$objSearcher.SearchRoot = New-object System.DirectoryServices.DirectoryEntry(”LDAP://$strContainer)
$objSearcher.PageSize = 1000
$objSearcher.Filter = $strFilter
$objSearcher.SearchScope = “Subtree”
$colServers = $objSearcher.FindAll()
ForEach($objServer in $colServers)
{
[String]$Server = $objResult.Properties.name
$Mailboxes = $Null
$Mailboxes = Get-WmiObject -NameSpace Root\MicrosoftExchangeV2 -Class Exchange_Mailbox -Computer $Server
$Mailboxes | Export-Csv "C:\Mailboxes_$Server.csv" -NoTypeInformation
}

Hope this helps.

All information is provided on an AS-IS basis, with no warranties and confers no rights.

Searching for DL's with Exchange Expansion Servers

Monday, June 8th, 2009

Question:

Do we have any Email enabled groups in Active Directory that have an Exchange 2003 expansion server explicitly specified in its properties and who manages them? 

Expansion Server:

“Exchange server dedicated to expanding the members of a specific mail enabled group (distribution list)”

Answer:

So I would need to look at  Active Directory for all email enabled distribution lists that have the attribute ‘msExchExpansionServerName’ (which only exists when a group is mail enabled), and that it’s value is not blank. If the attribute is blank the distribution list is set to default which is ‘Any server in the organization’. The value can be viewed on the ‘Exchange Advanced’ TAB on the groups properties in ADUC.

Here is the PowerShell one line command that I used. I am utilizing the Quest Active Roles Management cmdlets.

You will need the following:

  1. DN, GUID or Canonical Name of the Domain or Container where you wish to search for groups. (The example quotes a DN for the group container)
  2. Quest Active Roles Management Shell snapin.
Get-QADGroup -SearchRoot 'OU=GrouOU,DC=company,DC=com' -SizeLimit 0 -LdapFilter '(msExchExpansionServerName=*)' -IncludeAllProperties | Select-Object name,msexchexpansionservername,managedby

If you need any assistance in using the Quest Active Roles Management cmdlets see this article.

Note:

I use the ‘-IncludeAllProperties’property of the ‘Get-QADGroup’ cmdlet to ensure the ‘msExchExpansionServerName’ attribute is returned into the local cached object result set, by default this would not be returned, for more information see this article..

Hope this helps.

All information is provided on an AS-IS basis, with no warranties and confers no rights.

Populating Outlook forms with AD User Attributes

Friday, June 5th, 2009

Did you ever want an Custom Outlook Form to automatically populate a Custom Outlook Field with the Active Directory .displayName of the logged on user?

The code below populates the custom Outlook Fields “LOUDisplay”,”LOUGivenName”,”LOUSN” upon the creation of the Form.

This action does not repeat if the item is re-opened. This is restricted because the code is initiated only when the Item_Open() event occurs and Item.size = “0″ or newly generated. You will have to add this code in the Visual Basic part of the Custom Form.

Function Item_Open()
If Item.Size = "0" Then 'Item is New
Set objSysInfo = CreateObject("ADSystemInfo")
objUser = objSysInfo.UserName
Set ADOUser = GetObject("LDAP://"&objUser)
StrDisplayName = ADOUser.displayName
StrGivenName = ADOUser.givenName
StrSN = ADOUser.SN
Item.UserProperties("LOUDisplay") = StrDisplayName
Item.UserProperties("LOUGivenName") = StrGivenName
Item.UserProperties("LOUSN") = StrSN
Else 'Item Exists
End If
End Function

If you want any other properties for the logged on user accessing the Form just add to the fields pulled from ADUser and link to the required custom field.

Hope this helps.

All information is provided on an AS-IS basis, with no warranties and confers no rights.

Scheduling ExMON Traces in Exchange 2003

Thursday, June 4th, 2009

When monitoring Mapi Client statistics, having to manually run the traces can be a troublesome.
After some investigation I found a way to schedule the EXMON traces using a tool called “Tracelog.exe” which is part of the W2000 Resource Kit.

Windows 2000 Resource Kit: Tracelog
Exchange User Monitor: ExMON

For this posting I will assume you have EXMON installed and have also run the installation for the Windows 2000 Resource Kit tool “TraceLog” found above.There are obviously several ways you can both schedule and manipulate the Exchange traces. For me the simplest is to create a folder, preferably on another local disk not your “system” drive. In the folder place both the “tracelog.exe” from the tracelog installation folder and a copy of the “.guid” file from the EXMON application folder.

Once created you can then proceed to create the Schedule jobs in the AT Scheduler.

You will need to create two scheduled jobs, one to start the trace and one to stop the trace.

Start Trace Command:
Tracelog.exe -start [sessionid] -guid [GUID file location] -f [Trace file location]

E.g.

TRACELOG.EXE -start "Exchange Trace" -guid guid.txt -f Trace.etl

Stop Trace Command:
Tracelog.exe -stop [sessionid]

E.g.

TRACELOG.EXE -stop "Exchange Trace"

Utilizing the above command in scheduled jobs, will enable you to schedule captures of Exchange User/Client Mapi session information. I normally embed the commands in batch files and add commands to rename and move the capture files off the DAS on the physical system. This will eliminate the need to keep track of the files and move them to prevent disks usage issues.

E.g.

In a command file you could have the following commands to stop a trace, rename and move a file.

TRACELOG.EXE -stop "Exchange Trace"Rename D:\trace.etl \\Remote\Server_EXMON-%date:~4,2%-%date:~7,2%-%date:~10,4%.etl

Hope this helps.

All information is provided on an AS-IS basis, with no warranties and confers no rights.