SMTP Port 25

Anything and Everything Related to Messaging and Collaboration, Active Directory and Scripting. It’s My Life!!!

Archive for October, 2009

Windows 2008 R2 Powershell AD Cmdlets

Posted by Krishna - MVP on October 29, 2009

Widows 2008 R2 comes with powershell v2 by default. and added with 76 new Ad cmdlets and Ad provders

New-ADOrganizationalUnit -Name “OUname” -ProtectedFromAccidentalDeletion $true

This command creates new OU under the root. If we wanted created OU in specific path then we have to provide the pat. Below is the example of the same

New-ADOrganizationalUnit -Name “OUname” -Path “OU=AllUsers,dc=grayson,dc=test”  -ProtectedFromAccidentalDeletion $true

-ProtectedformAccidentDeletion $true help to protect the OU getting accidentially deleted.

Get-ADOrganizationalUnit

Helps to get the details of the required OU

Set-ADOrganizationalUnit

Helps to modify the OU

Remove-ADOrganizationalUnit

Helps to remove the required OU

Posted in Powershell, Windows 2008 | Tagged: , , | Leave a Comment »

Powershell to send email with delivery notification enabled

Posted by Krishna - MVP on October 28, 2009

Powershell to send email with delivery notification enabled. Once mail is delivered to the recipient mailbox and delivery notification mail will be sent to the sender mailbox. Below powershell help you to atchive the same

$msg = new-object Net.Mail.MailMessage
$smtp = new-object Net.Mail.SmtpClient($smtpServer)
$msg.Headers.Add(“Disposition-Notification-To”, “from@domainname.com”)
$msg.DeliveryNotificationOptions = “OnSuccess”
$msg.From = “from@domainname.com”
$msg.To.Add(”to@domainname.com”)
$msg.Subject = “Make the Delivery Recipt Work Please”
$msg.Body = “In a perfect world this email will generate a delivery receipt”
$msg.Attachments.Add($att)
$smtp.Send($msg)

Posted in Exchange 2007, Powershell | Tagged: , , , | 1 Comment »

Powershell to Settup ManagedFolderAssistantSchedule in all Exchange 2007 Mailbox Servers

Posted by Krishna - MVP on October 15, 2009

The managed folder assistant is a Microsoft Exchange Mailbox Assistant that creates managed folders in users’ mailboxes and applies managed content settings to them. When the managed folder assistant is running, it processes all of the mailboxes on a server. If the managed folder assistant does not finish processing the mailboxes on the server during the time that you have scheduled, it automatically resumes processing where it left off the next time it runs. There is one managed folder assistant for each server

Get-ExchangeServer | Where { $_.AdminDisplayVersion.ToString().SubString(0, 10) -eq “Version 8.” `

-and $_.ServerRole -eq “Mailbox” } |

ForEach { Set-MailboxServer -Identity $_.Identity `

-ManagedFolderAssistantSchedule “Sun.1:00 AM-Sun.3:00 AM”, `

“Mon.1:00 AM-Mon.3:00 AM”, “Tue.1:00 AM-Tue.3:00 AM”, `

“Wed.1:00 AM-Wed.3:00 AM”, “Thu.1:00 AM-Thu.3:00 AM”, `

“Fri.1:00 AM-Fri.3:00 AM”, “Sat.1:00 AM-Sat.3:00 AM” }

http://technet.microsoft.com/en-us/library/bb123958.aspx

Posted in Exchange 2007 | Tagged: , , , | Leave a Comment »

LogParsing with Exchange SMTP Protocol Logs

Posted by Krishna - MVP on October 14, 2009

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

SMTPVirtualServer

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

Logparset

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

http://smtpport25.wordpress.com/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

Posted in Exchange 2003, Exchange 2007, Powershell | 1 Comment »

SMTP Protocol Logging In Exchange 2007

Posted by Krishna - MVP on October 12, 2009

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

SendConnector

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

Posted in Exchange 2007, Powershell | Leave a Comment »

Using PowerShell in ASP.NET (.NET Framework 2.0)

Posted by Krishna - MVP on October 10, 2009

Blow link has some beautiful article on how use power shell asp.net framework

http://blogs.msdn.com/akashb/archive/2009/01/30/howto-using-powershell-in-asp-net-net-framework-2-0.aspx

Posted in Exchange 2007 | Tagged: , , , , | Leave a Comment »

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

Posted by Krishna - MVP on October 10, 2009

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)
}

Posted in Exchange 2007, Powershell | Tagged: , , , , | Leave a Comment »

Restricting Exchange 2007 users to force outlook Cached mode

Posted by Krishna - MVP on October 7, 2009

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

Posted in Exchange 2007, Powershell | Tagged: , , , | Leave a Comment »

Powershell to Export Exchange backup Status to Email in HTML format

Posted by Krishna - MVP on October 6, 2009

$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

Posted in Exchange 2007, Powershell | 1 Comment »

Powershell to Get Exchange mailbox Database and Public Backup Status Report

Posted by Krishna - MVP on October 6, 2009

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

Posted in Exchange 2007, Powershell | Tagged: , , | 1 Comment »

 
Follow

Get every new post delivered to your Inbox.

Join 49 other followers