LogParsing with Exchange SMTP Protocol Logs

SMTP Protocol logs are not enabled by default.  In Both Exchange 2003 and Exchange 2007 SMTP Protocol logs need to be manually enabled.

In Exchange 2003 SMTP protocol logging is enabled on the SMTP Virtual Servers

Please download log parser from following link

http://www.microsoft.com/downloads/details.aspx?FamilyID=890cd06b-abf8-4c25-91b2-f8d975cf8c07&displaylang=en

Below log parser command help you to get list of servers connecting to Exchange 2003 server through SMTP

logparser “Select cs-username,count (*) as Hits from N:\ex0910.log GROUP BY cs-username ORDER BY Hits Desc” -o:DATAGRID

Below is the output it provides the list of server name and number of hits from that specific servers

Below mentioned article describes on how to enabled smtp protocol logging on Exchange 2007 and log files path

/2009/10/

Below command helps you to get the list of servers connect to the exchange server for sending emails

logparser “select REVERSEDNS(EXTRACT_PREFIX(remote-endpoint,0,’:’)) as RemoteSendingHost, count(*) as Hits from RECV*.log group by RemoteSending Host order by Hits DESC” -i:CSV -nSkipLines:4  -o:DATAGRID

related articles

http://msexchangeteam.com/archive/2007/09/12/446982.aspx
http://msexchangeteam.com/archive/2007/11/12/447515.aspx
http://msexchangeteam.com/archive/2007/11/28/447598.aspx
http://linuxlore.blogspot.com/2006/11/howto-use-microsofts-logparser-to.html

SMTP Protocol Logging In Exchange 2007

Exchange Protocol Logging is not Enabled by Default in Exchange 2007. We have to enable the logging if required. Below powershell commands help you to enable the

Set-SendConnector “Send Connector Name” -ProtocolLoggingLevel verbose
Set-ReceiveConnector “Connector Name” -ProtocolLoggingLevel verbose

You can also enable the connector through Exchange Management Console.

EMC -> Exchange Orginization -> Hub Transport Servers -> Send connectors (tab) -> Right click on the required connector properties -> select Verbose

Location of STMP Logs in the below mentioned location
\Exchange Server\TransportRoles\Logs\ProtocolLog\SmtpReceive
\Exchange Server\TransportRoles\Logs\ProtocolLog\SmtpSend

Powershell Script to check Health Services running in all Exchange 2007 servers

Below power shell Command Gets Each of the Exchange 2007 Server in the Environment and Check the Health Services then display the status.  Exchange Services varies depend on the type of services installed. Mailbox Services , Hubtransport Servers, Client Access server has some common service and some unique services. Test-Serverhealth performs the health check only on required services depending on the type of server Installed.

$ExchServer=Get-ExchangeServer
foreach ($Server in $ExchServer)
{
echo $Server.name (Test-ServiceHealth $Server)
}

Restricting Exchange 2007 users to force outlook Cached mode

Outlook clients are used to connect to the Exchange 2007 to access email. Non – Cached Mode clients can generate a significant amount of disk I/O traffic and affect the performance of the server. Forcing all clients to use Cached Mode can Improve the  performance

Below powershell forces to apply the same for all the users

Get-Mailbox | Set-CASMailbox -MAPIBlockOutlookNonCachedMode $true

Below power shell helps to apply for the Individual users

Get-mail username | Set-CASMailbox -MAPIBlockOutlookNonCachedMode $true

Powershell to Export Exchange backup Status to Email in HTML format

$wid  = “1200”
$bord = “2”
$colour =”BLUE”
$Fcolour = “White”

“<table width=$wid border=$bord>” | out-file -filePath “C:\Powershell\BackupDetails.txt” -append
“<tr> ” | out-file -filePath “C:\Powershell\BackupDetails.txt”  -append
“<td BGCOLOR=$colour><font color=$Fcolour> <b>Server</b></td> ” | out-file -filePath “C:\Powershell\BackupDetails.txt”  -append
“<td BGCOLOR=$colour><font color=$Fcolour> <b>StorageGroupName</b> </td> ” | out-file -filePath “C:\Powershell\BackupDetails.txt”  -append
“<td BGCOLOR=$colour><font color=$Fcolour><b>LastFullBackup</b></td> ” | out-file -filePath “C:\Powershell\BackupDetails.txt”  -append
“<td BGCOLOR=$colour><font color=$Fcolour><b>LastIncrementalBackup</b></td> ” | out-file -filePath “C:\Powershell\BackupDetails.txt”  -append
“<td BGCOLOR=$colour><font color=$Fcolour><b>BackupInProgess</b></td> ” | out-file -filePath “C:\Powershell\BackupDetails.txt”  -append
“</tr> ” | out-file -filePath “C:\Powershell\BackupDetails.txt”  -append

Get-MailboxDatabase | where {$_.Recovery -eq $False } | Select-Object -Property Server, StorageGroupName, Name , LastFullBackup, LastIncrementalBackup, BackupInProgess | Export-csv Backuptatus.csv

foreach($line in $csv)
{
$MailboxStats =  Get-MailboxStatistics  $Line.Alias | Select TotalItemSize,Itemcount,LastLogoffTime,LastLogonTime
$L = “{0:N0}” -f $mailboxstats.totalitemsize.value.toMB()
$Size = “”
$Len = $L.Split(‘,’)
for ($i=0; $i -lt $Len.length; $i++)
{
$Size = $Size +$Len[$i]
}
$temp=$Line.PrimarysmtpAddress
$adobjroot = [adsi]”
$objdisabsearcher = New-Object System.DirectoryServices.DirectorySearcher($adobjroot)
$objdisabsearcher.filter = “(&(objectCategory=Person)(objectClass=user)(mail= $Temp)(userAccountControl:1.2.840.113556.1.4.803:=2))”
$resultdisabaccn = $objdisabsearcher.findone() | select path

“<tr> ” | out-file -filePath “C:\Powershell\BackupDetails.txt”  -append
“<td BGCOLOR=$colour><font size=2 color=$Fcolour> <b> $Line.Server </b></td> ” | out-file -filePath “C:\Powershell\BackupDetails.txt”  -append
“<td BGCOLOR=$colour><font size=2 color=$Fcolour><b>$Line.StorageGroupName</b> </td> ” | out-file -filePath “C:\Powershell\BackupDetails.txt”  -append
“<td BGCOLOR=$colour><font size=2 color=$Fcolour><b>$Line.Name</b></td> ” | out-file -filePath “C:\Powershell\BackupDetails.txt”  -append
“<td BGCOLOR=$colour><font size=2 color=$Fcolour><b>$line.LastFullBackup</b></td> ” | out-file -filePath “C:\Powershell\BackupDetails.txt”  -append
“<td BGCOLOR=$colour><font size=2 color=$Fcolour><b>$Line.LastIncrementalBackup</b></td> ” | out-file -filePath “C:\Powershell\BackupDetails.txt”  -append
“<td BGCOLOR=$colour><font size=2 color=$Fcolour><b>$Line.BackupInProgess</b></td> ” | out-file -filePath “C:\Powershell\BackupDetails.txt”  -append
“</tr> ” | out-file -filePath “C:\Powershell\BackupDetails.txt”  -append
}

$smtpServer = “hutserver”
$msg = new-object Net.Mail.MailMessage
$smtp = new-object Net.Mail.SmtpClient($smtpServer)
$msg.From = “FromAddress”
$msg.To.Add(”ToAddress”)
$sub = Date
$msg.Subject = “Exchange Database Backup Status Report  ” + $sub

$msg.IsBodyHTML = $true

$UserList = Get-Content “C:\Powershell\BackupDetails.txt”

$body = “”

foreach($user in $UserList)
{
$body = $body + $user + “`n”

}

$msg.Body = $body

$smtp.Send($msg)
Exit

Please find the copy of the in the below link

http://powershell.com/cs/members/smtpport25.wordpress/files/BackupStatus.ps1.aspx

Powershell to Get Exchange mailbox Database and Public Backup Status Report

Below power shell help you to get backup status of all the Exchange Database in Exchange 2007 Servers

Get-MailboxDatabase `
| where {$_.Recovery -eq $False } `
| Select-Object -Property Server, StorageGroupName, Name , LastFullBackup, LastIncrementalBackup, BackupInProgess `
| Sort-Object -Property Server, StorageGroupName, Name `
| Format-Table -AutoSize

Get-PublicFolderDatabase `
| Select-Object -Property Server, Storagegroupname, Name , LastFullBackup, LastIncrementalBackup, BackupInProgess `
| Sort-Object -Property Server, StorageGroupName, Name `
| Format-Table -AutoSize

Enabeling and Disabiling Active Sync for the user

Windows Mobiles can be configured for Active Sync. Active Sync is enabled for all users by Default in Exchange 2007. For Security reasons its recommended to disabled all users and enable only for the required users

Below power shell enabled and disabled Active for all the users in the exchange Organization

get-Mailbox -resultsize unlimited | set-CASMailbox -ActiveSyncEnabled:$False

get-Mailbox -resultsize unlimited | set-CASMailbox -ActiveSyncEnabled:$True

Below powershell command to enable and disable active sync for given set of users in the text file

Get-content C:\users.txt | set-CASMailbox -ActiveSyncEnabled:$True

Get-content C:\users.txt| set-CASMailbox -ActiveSyncEnabled:$True

Below powershell command to get the list of users who ActiveSync is Enabled and Disabled

Get-CASMailbox -ActiveSyncEnabled:$True

Get-CASMailbox -ActiveSyncEnabled:$False

Add-ADPermission with Exchange 2007 databases

 

Add-ADPermission cmdlet is used to provide permission to Active directory object.  This article explains you how to provide Access Exchange 2007 Database .  Below command sets permission on the Exchange Mailbox Stores and enables the AdminAccount to access uses mailboxes to  view, move, and delete messages, etc 

Get-MailboxDatabase | Add-ADPermission -User domain\Adminaccount –ExtendedRights ms-Exch-Store-Admin

Above command should workd prefectly fine, If you get any errors in executing above command then you may have to do some work around solution to set this

Add-Adpermission -identity “CN=InformationStore,CN=Exchange2007name,CN=Servers,CN=Exchange Administrative Group,CN=Administrative Groups,CN=company,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=Domain,DC=com” -User “Domain\adminAccount” –ExtendedRights ms-Exch-Store-Admin

Above command helps you the fix the problem. you may have to provide AD Distinguished Name for the Informatio store of the specific server to provide Extended Rights on access to all the Database of the specific the Exchange server. To Provide access to Individual Storage gropue then you may have to try something link this

Add-Adpermission -identity “SG=StorageGroupname,CN=InformationStore,CN=Exchange2007,CN=Servers,CN=Exchange Administrative Group,CN=Administrative Groups,CN=Our Company,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=myDomain,DC=com” -User “Domain\adminAccount” –ExtendedRights ms-Exch-Store-Admin

 

Add-Adpermission -identity “CN=Databasename,CN=StorageGroupname,CN=InformationStore,CN=Exchange2007,CN=Servers,CN=Exchange Administrative Group,CN=Administrative Groups,CN=Our Company,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=myDomain,DC=com” -User “Domain\adminAccount” –ExtendedRights ms-Exch-Store-Admin