Add-IPAllowListEntry

IP Allow List is used to add the list of IP address into Exchange server to allow computer with IP address to use exchange server for relay purpose and mail sent for the computer which is added in IP Allow list is not scan by anti-spam agent. With this mail comming from the machine with IP allow list will not be sent to spam mails or Junk mail folder. To do this need to make sure that Anti-Spam agent is intalled on the Hub server

Instruction on how install Anti spam agent. Need to make sure you run on all the Hub Transport server

1. Open powershell -> Navigate to the folder “Program Files\Microsoft\Exchange Server\Scripts”
2. Type ./install-AntispamAgents.ps1 and Enter to install the same to get the below output

 

3. Restart the “Microsoft Exchange Transport” service from services
4. Open the Exchange Management Console -> Organization configuration -> select Hub Transport.
5. The “Anti-Spam” tab should be visible in Hub Transport properties. Make sure that IP Allow List is enabled. If not right click and enabled the same

 

Instruction on How to add IP address and IP address range into allow list can be find in the below link.

http://technet.microsoft.com/en-us/library/bb125225(EXCHG.140).aspx

Powershell to apply Fullaccess and Send as permission to Exchange 2007 Mailbox

Below powershell can help to apply users full access rights and and SendAs permission to the mailbox for the given input CSV file

Format ofthe CSV something like this

UserMailbox,User
Krishna,Domain/Krishna

———————————————————————————————————————-

$csv = Import-csv -path “C:\Userdetails.csv”
foreach($line in $csv)
{
Add-MailboxPermission $Line.UserMailbox -AccessRights FullAccess -user $Line.User
Add-ADPermission $Line.UserMailbox -Extendedrights “Send As” -User $Line.User

}

———————————————————————————————————————-

Powershell to get the list of user who last logon time is older then 30 days

Below is the powershell command to get the list of mailbox who last log time is older then 30 days. This would be very help ful when you wanted to try to clean up exchagne server from unused account.  You can change from 30 to 6o or 90 days based on the requirement.

Get-MailboxStatistics | where {$_.Lastlogontime -lt (get-date).AddDays(-30)} | Select displayName,LastLoggedOnUserAccount,LastLogonTime

Managing Deleted Items under Default Managed folders in Exchange 2007

Default Manged folders are managing the default folders which is created by default in every mailbox like Inbox, Deleted Items, Send Items etc. Its Important that we managed some of the folders like Deleted items and sent items to keep storage utilization under control. Below is the step by step to configure to configure Mails in Deleted Items folder which are older than 30 Days

1. Open Exchange management console and click on Orgnisation Mailbox and on the right, click on Managed default folder to get the below snap. This is the list of items in Default managed folder. Same we cam get throught power shell

Get-ManagedFolder

2. Right click Delete Items and click on New Managed content settings and enter the details like show below snap and click on next and new to complete the same. Which alsow to input the details like whats the retention period of the deleted items, what action has to be done , when retention priod reaches. Same can be done with the powershell command

new-ManagedContentSettings -Name ‘Delete_DeletedMails_30Daysold’ -FolderName ‘Deleted Items’ -RetentionAction ‘DeleteAndAllowRecovery’ -AddressForJournaling $null -AgeLimitForRetention ‘30.00:00:00’ -JournalingEnabled $false -MessageFormatForJournaling ‘UseTnef’ -RetentionEnabled $true -LabelForJournaling ” -MessageClass ‘*’ -MoveToDestinationFolder $null -TriggerForRetention ‘WhenMoved’

3. Once we are done this then we have to create Managed mailbox folder policy and added Managed folders(deleted items) and apply the same to the required mailboxes. To do this right click on Mailbox on Microsoft Exchange orginisation  in EMC and in the Result pane click on Managed folder policy and in the Action pane click on “New Managed Folder Default policy” and enter the required details as shown in the below snap and add Deleted Items and click on New to create the same. Same can be done with Powershell command

new-ManagedFolderMailboxPolicy -Name ‘DeletedItems_Retention_Policy’ -ManagedFolderLinks ‘Deleted Items’

 

4. Now need to apply to the individual user by going to the individual mailbox properties from Exchange management console properties ->  Mailbox settings -> double click on Message Records Management and browse and apply the new managed folder maibox policy created and apply the same.  Below is the snap of the same. Same also can be done with powershell command

Set-Mailbox -Identity <username> -ManagedFolderMailboxPolicy “Managed Folder Mailbox Policy Name”

To apply all the mailbox in the Exchange orginisation

Get-Mailbox  |Set-Mailbox -Identity <username> -ManagedFolderMailboxPolicy “Managed Folder Mailbox Policy Name”

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

5. Once we apply the policy to the mailboxes we have schedule the policy to run every day.  Right click on the Exchang Mailbox server -> Properties under Server Configuration and click on Messaging Records Management and Customise the required time

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

6.  You can force this settings to apply for the individual server or mailbox using below mentioned command

Start-ManagedFolderAssistant –Mailbox <Mailbox>
Start-ManagedFolderAssistant –Identity <ServerName>

Configuring Exchange 2007 Client Access Server with LoadBalancer

To configure Multiple Exchange 2007 client access server with load balancer we need to Offload Certificate to the load balancer.

Offloading Certificate is the process where we uploaded certificate into the load balancer and this box will accept the request and decrypt the certificate and it will create a new session from the load balancer to the exchange servers. This is called SSL termination where SSL Session from the client is terminated at the LB and new session is created between the Server and Load Balancer

To configure SSL offloading for Outlook Web Access, you must perform the following procedure on each of your Client Access servers. Below is the link which gives the details description on configuring Client Access Servers

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

Below link on F5 Load balancer which has details description on how to configure for Exchange 2007 Client Access server for OWA, Active Sync, Pop3, IMAP etc

http://www.f5.com/pdf/deployment-guides/f5-exchange07-dg.pdf

Exchange 2007 soft recovery of the database

Soft Recovery is the process of remounting the database when the database was shutdown abruptly and when log files and Database files are intact.

 Simple Soft Recovery Process

Mounting of the database is simple soft recovery process which will check the checkpoint file and find the log latest log updated and will update the remaining logs.  If there you no check point it will try to apply oldest log files available. 

 

Advanced Soft Recovery Process (Careful, Make sure that you have the copy of the database and log files before you do this option)

When there is abrupt shutdown and there are chances that Database may go into Dirty shutdown state. When you try to mount the database it may not mount as it is the Dirty Shutdown state. Need to reply the logs manually to bring the database into clean shutdown state.

 

1.  Eseutil /mh “Databasepath” (gets you the details of the clean shutdown or dirty shutdown)

Below snap give the details of the dirty shutdown and it also provide the details of Log Required.

 

 

2. Eseutil /ml “Path of the log file” (get you the header of the logs and there you will find the value of Base name: E00 to use for the applying the logs. This may vary in the log header. Need to make sure that you get the database before you apply the logs

 

3. Move the Check point file the other location .This will cause to replay all the logs available

 

4. Open command prompt and browse to the log file location and run the below mentioned command

 Eseutil /r  /a E00 /d “C:\EDB file path” /S “C:\Log file path” /L “C:\Chckpoint file creation path”

 Make sure that you taken the backup of the log file before you use these options and you make sure that you have all the log file required as per the header of the Database and provide the correct paths. For the simple recovery use below mentioned command

 Eseutil /r E00

 5. On completion it should mount automatically or you can mount the database from Exchange management console. We can checked if Datbase is been changed to clean shutdown form the below mentioned command

 Eseutil /mh “Database path.edb”

Powershell to get Complete Mailbox Statistics in the Exchange 2007 Orginisation

 

Below is the powershell command to export the complete details of the Mailbox in the Exchange Organization. Details like Name, Mailbox size (MB), Mailcount, Mailbox limits, Account Active or disabled, CreatedDate, Lastlogon time, Last logofftime etc into the CSV file. This Data can even imported in to the SQL database and Query to analyst the growth of the mailbox. If you collect these details on Daily basis and uploaded into SQL then you can easily get the details of the mailbox in seconds for auditing or capacity management etc.

With SQL integration you can query details like Top 100 mailbox, Top 100 Fastest growing mailbox, List of all active maibox, List of disabled mailbox, List of mailbox out of default quota limits, maiboxes not used in past few days. Newly created mailbox in past one month etc

Get-Mailbox -ResultSize Unlimited |  select DisplayName, Alias, Database, PrimarySmtpAddress,@{name=’IssuewarningQuota’;expression={if ($_.IssueWarningQuota -match “UNLIMITED”) {“-1”} else {$_.IssueWarningQuota.value.tomb() }}},@{name=’ProhibitSendQuota’;expression={if ($_.ProhibitSendQuota -match “UNLIMITED”) {“-1”} else {$_.ProhibitSendQuota.value.tomb() }}},@{name=’ProhibitSendReceiveQuota’;expression={if ($_.ProhibitSendReceiveQuota -match “UNLIMITED”) {“-1”} else {$_.ProhibitSendReceiveQuota.value.tomb() }}},WhenCreated  |export-csv C:\stats.csv
“DisplayName,Alias,MailboxSizeMB,ItemCount,PrimarysmtpAddress,IssueWarningQuotaMB,ProhibitSendQuotaMB,ProhibitSendReceiveQuotaMB,DatabaseName,CreationDate,LastLogonTime,LastLogoffTime,isActive” | out-file C:\MailstatsResult.csv
$csv = Import-csv -path “C:\stats.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

if($resultdisabaccn.path)
 {
 $actStatus = “1”
 }
 Else
 {
 $actStatus = “0”
 }
 
 $out =$Line.Displayname  + “,” + $Line.Alias  + “,” +  $Size + “,” + $MailboxStats.ItemCount  + “,” + $Line.PrimarySmtpAddress   + “,” +  $Line.IssueWarningQuota + “,” +  $Line.ProhibitSendQuota  + “,” +  $Line.ProhibitSendReceiveQuota + “,” + $Line.Database + “,” +  $Line.WhenCreated + “,” + $MailboxStats.LastLogonTime + “,” + $MailboxStats.LastLogoffTime + “,” + $actStatus
 $Out | Out-File C:\MailstatsResult.csv -Append
}

You can get the copy of the script in the below text file

http://powershell.com/cs/cfs-filesystemfile.ashx/__key/CommunityServer.Components.UserFiles/00.00.00.30.62/MailboxStats.txt

Count of Mailbox Created in last Week/Month

 

We always for some reason need to find the count of the mailbox created in last week/Month etc. Below is the powershell command to get the count

$Result = Get-Mailbox -resultsize unlimited | where {$_.WhenCreated -gt (get-date).AddDays(-30)} | Select displayName
$Result.Count

To get the details to the text file you can use the below mentioned command to export to the text file

Get-Mailbox -resultsize unlimited | where {$_.WhenCreated -gt (get-date).AddDays(-30)} | Select displayName, Servername,Database, WhenCreated >> Result.txt

Exchange Database and Transactions log Reset

Chances that some times Database has grow too big or some time database is corrupted , then you may have to move all the user to the different store and reset the Database

Reset Database – Care full while doing this task. Make sure that you select the right DB

1. Select the require Exchagne database from Exchange system manager or Exchange management console
2. Right click on the database and click on Dismount
3. Find the path of the database. Select Edb and Stm file and rename the file(Can be deleted later)
4. Right click on the database and click on Mount
5. This will create a new database with the same old Database name.
6. You can start moving users

 

Reset Transaction Logs – Careful while doing this task. Make sure that you select the right Storage Group

1. Transaction Logs are for each Storage group. In exchange 2007 it’s recommended to have one database on each storage group. Managing would be easy when you have one database in each storage group. We can always have multiple databases
2. Stop Information store service
3. Run Eseutil /mh “Database Path” on each of the database which you wanted to transaction log reset. Make sure that you get “Clean Shutdown” status.

 4. Once you have clean shutdown on all the databases then you can go to the log folders and move all the files to the temp location
5. Start the Information store service again