Showing posts with label Exchange. Show all posts
Showing posts with label Exchange. Show all posts

Tuesday, 2 June 2015

How to Remove the Header of CSV file

#TYPE System.Management.Automation.PSCustomObject

 
To eliminate the above header from CSV file while using Export-CSV command, add -NoTypeInformation

Export-CSV "Location where you want to save the CSV file" -NoTypeInformation

Wednesday, 22 April 2015

How to check if a remote server is reachable

You can store the servers in $Servers variable

_________________________________________________________________

$Servers = "Server1","Server2","Server3"

Foreach ($Server in $Servers)
{

  $StatusPC = Test-Connection -Cn $Server -BufferSize 16 -Count 1 -ea 0 -quiet

      if ($StatusPC -eq $True)
       {    
       Write-host
       Write-host "$Server is reachable" -foregroundcolor Green -backgroundcolor black
       }

       else
       {
        Write-host
        Write-host "$Server is not reachable" -foregroundcolor Red -backgroundcolor black
       }

}

       Write-host


_________________________________________________________________

Note: If the servers are reachable you will be able to see the output in Green if not then you will see Red 


Alternate One-Liner Script:
get-content servers.txt | % {new-object psobject -property 
@{ComputerName=$_; Reachable=(test-connection -computername $_ -quiet -count 1)} }  
| ft -AutoSize

Tuesday, 2 September 2014

Exchange Availability Report

Add-PSSnapin *exchange*
$report1 = "C:\dailyreports\Test.availability\Test.availability.htm"
Clear-Content $report1
Add-Content $report1 "<html>"
Add-Content $report1 "<head>"
Add-Content $report1 "<meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'>"
Add-Content $report1 '<title>Availability report for Exchange servers</title>'
add-content $report1 '<STYLE TYPE="text/css">'
add-content $report1  "<!--"
add-content $report1  "td {"
add-content $report1  "font-family: Tahoma;"
add-content $report1  "font-size: 11px;"
add-content $report1  "border-top: 1px solid #999999;"
add-content $report1  "border-right: 1px solid #999999;"
add-content $report1  "border-bottom: 1px solid #999999;"
add-content $report1  "border-left: 1px solid #999999;"
add-content $report1  "padding-top: 0px;"
add-content $report1  "padding-right: 0px;"
add-content $report1  "padding-bottom: 0px;"
add-content $report1  "padding-left: 0px;"
add-content $report1  "}"
add-content $report1  "body {"
add-content $report1  "margin-left: 5px;"
add-content $report1  "margin-top: 5px;"
add-content $report1  "margin-right: 0px;"
add-content $report1  "margin-bottom: 10px;"
add-content $report1  ""
add-content $report1  "table {"
add-content $report1  "border: thin solid #000000;"
add-content $report1  "}"
add-content $report1  "-->"
add-content $report1  "</style>"
Add-Content $report1 "</head>"
Add-Content $report1 "<body>"
add-content $report1 "<table width='100%'>"
add-content $report1  "<tr bgcolor='#CCCCCC'>"
add-content $report1  "<td colspan='7' height='25' align='center'>"
add-content $report1  "<font face='tahoma' color='#003399' size='4'><strong>Server Name</strong></font></td></tr></table>"
add-content $report1  "<table width='100%'>"
Add-Content $report1 "<tr bgcolor=#CCCCCC>"
Add-Content $report1  "<td width='10%' align='center'>ServerName</td>"
Add-Content $report1  "<td width='10%' align='center'>Timegenerated</td>"
Add-Content $report1 "<td width='10%' align='center'>EventId</td>"

Add-Content $report1 "</tr>"

$all = (get-eventlog System -ComputerName TestExchSvr -After 7/1/2014 | Where-Object {($_.eventid -eq "6005") -or ($_.eventid -eq "6006")})

Set-ADServerSettings -ViewEntireForest $True
foreach ($a in $all)
  { 

$Machinename=$a.Machinename
$Time=$a.timegenerated
$EventId=$A.eventId
      
Add-Content $report1 "<td align=center width='20%' align='center' bgcolor='#00FF00'>$Machinename</td>"
Add-Content $report1 "<td align=center width='20%' align='center' bgcolor='#00FF00'>$Time</td>"
Add-Content $report1 "<td align=center width='20%' align='center' bgcolor='#00FF00'>$EventId</td>"

Add-Content $report1 "</tr>"

}

Add-Content $report1 "</table>"

Add-Content $report1 "</body></html>"

$from = "exchangemonitoring@testsvr.com"
$to = "vishwajeet.sharma@testsvr.com"
$subject = "Availability Report- Exchange Servers"
$body = Get-Content $report1
$smtp= New-Object System.Net.Mail.SmtpClient 
$msg = New-Object System.Net.Mail.MailMessage $from, $to, $subject, $body
$msg.isBodyhtml = $true
$smtp.Host = "192.168.1.3"
$smtp.send($msg)
exit 0

Tuesday, 15 July 2014

Sorry! We're having trouble processing your request right now. Please try again in a few minutes

If you receive the error "Sorry! We're having trouble processing your request right now. Please try again in a few minutes" while accessing the ECP console.

To fix the ECP issue, follow the below steps

1. Check the connection statistics in Exchange
2. Stop the services HpExMon and HpExMonWD and set it as manual. This will disable the server from LB.
3. Check the connection statistics in Exchange again there shouldn t be any new connections to the server.
4. Stop IISadmin and W3SVC (World Wide Web Publishing Service)
5. Go to "C:\Windows\Microsoft.NET\Framework64\v2.0.50727\Temporary ASP.NET Files" and rename ECP directory to "ECP-old"
6. Start IISadmin and W3SVC (World Wide Web Publishing Service)
6. test whether issue persists or not. If the issue persists go to step 9.
7. If the issue is resolved, start HpExMon and HpExMonWD services and set it as automatic. This will enable the server LB.
8. Check the connection statistics in Exchange and make sure the server is accepting the sessions. This ends the troubleshooting.
9. Remove the ECP virtual directory using the following command, Remove-EcpVirtualDirectory -Identity "EXCHTESTSVR\ecp (default Web site)"
10. Create new ECP virtual directory using , New-EcpVirtualDirectory -externalurl "https://webmail.domain.com/ecp" -internalurl "https://webmail.domain.com/ecp" -Server "EXCHTESTSVR"
11.Restart IIS and verify the ECP functionality
12. Start HpExMon and HpExMonWD services and set it as automatic. This will enable the server LB.
13. Check the connection statistics in Exchange and make sure the server is accepting the sessions. This ends the troubleshooting.

Saturday, 5 July 2014

Script for Mailbox Move

##Importing the file 
####Ensure to remove "Target Database" Column with "TargetDatabase" with no space in input csv file

$all = Import-Csv .\Mailboxmove.csv

##Defining the batch name
$OurBatchName = "Mailbox Move - 5 July"

## Creating the move requests for users
foreach($a in $all) 


##Check and clear if there is any existing move request for the user 

Get-MoveRequest $a.PrimarySmtpAddress | Remove-MoveRequest -Confirm:$False

##Wait for 10 seconds before creating the move request 
Start-Sleep 10

##Create the move request 
New-MoveRequest $a.PrimarySmtpAddress -PrimaryOnly -TargetDatabase $a.TargetDatabase -BatchName $OurBatchName
}

Wednesday, 2 July 2014

Get the list of Active Sync Users on a particular OU

Get-ActiveSyncDevice | Where {$_.UserDisplayName -match "TestLab.com/TestOU"} | ft Userdisplay*, deviceid, Friendlyname, WhenCreated, deviceIMEI

Script to update email address

$all = Import-Csv C:\temp\test.csv

foreach($a in $all)
{
  $addr = (get-recipient $a.PrimaryEmail).EmailAddresses

  $temp1 = "smtp:" + $a.NewEmail

  $newaddr = $addr + $temp1

  Set-Mailbox $a.PrimaryEmail -EmailAddresses $newaddr
}



Notes:

In the test.csv there are two columns (PrimaryEmail & NewEmail)
.EmailAddresses is a property and this can be checked by running a command Get-Recipient | Get-member
If you want to make the new email as Primary SMTP address then replace "smtp:" with "SMTP:"


Wednesday, 18 December 2013

How to get the count of mailboxes per database

In order to find the mailbox count per database. Follow the below steps:
  1. Login to Exchange Server
  2. Open Exchange Management Shell
  3. Run the command as shown below to get the desired output.



Monday, 16 December 2013

Script to pull all the mailboxes created in 24 hrs on Exchange 2010

Get-Mailbox -ResultSize unlimited | Where {$_.WhenCreated -gt (Get-Date).AddDays(-1)}

If you need the details for 1 week, replace 1 with 7

Get-Mailbox -ResultSize unlimited | Where {$_.WhenCreated -gt (Get-Date).AddDays(-7)}

Friday, 4 October 2013

Extended Support End Date for Exchange 2003 is April 2014

Microsoft Support Life Cycle

Products Released                   Lifecycle Start Date   Mainstream Support End Date                  Extended Support End Date
Exchange Server 2003 Enterprise Edition 9/28/2003 4/14/2009                          4/8/2014                                        5/25/2005
Exchange Server 2003 Service Pack 1 5/25/2004 Not Applicable                 Not Applicable                        1/8/2008
Exchange Server 2003 Service Pack 2 10/19/2005 Review Note                         Review Note
Exchange Server 2003 Standard Edition 9/28/2003 4/14/2009                          4/8/2014                                         5/25/2005

Tuesday, 17 September 2013

Exchange 2013 CONF



Exchange CON Keynote Session: Key Issues in Managing Exchange
http://www.onlinemeetingnow.com/seminar/?id=bcbe605f0e

Exchange CON 2013 Breakout Session 1: MS Exchange Storage Managment Strategies
http://www.onlinemeetingnow.com/seminar/?id=dcbef9578a

Exchange CON 2013 Breakout Session 2: Making Highly Available Exchange Deployments Highly Available
http://www.onlinemeetingnow.com/seminar/?id=082a345494

Exchange CON 2013  Breakout Session 3: Backup & Security Strategies for MS Exchange in 2013 and Beyond
http://www.onlinemeetingnow.com/seminar/?id=60f79933b7

Exchange CON 2013 Breakout Session 4: Best Practices for Keeping Exchange Healthy
http://www.onlinemeetingnow.com/seminar/?id=fefb258c4e

Tuesday, 13 August 2013

Exchange 2010 SP3 Rollup 2 & SP2 RU7

Yesterday the Exchange Team released Rollup 2 for Exchange Server 2010 Service Pack 3 (KB2866475). This update raises Exchange 2010 version number to 14.3.158.1.

Here’s a list of fixes contained in this Rollup:
    • 2837926 Error message when you try to activate a passive copy of an Exchange Server 2010 SP3 database: “File check failed”
    • 2841150 Cannot change a distribution group that contains more than 1,800 members by using ECP in OWA in an Exchange Server 2010 environment
    • 2851419 Slow performance in some databases after Exchange Server 2010 is running continuously for at least 23 days
    • 2853899 Only the first page of an S/MIME signed or encrypted message is printed by using OWA in an Exchange Server 2010 environment
    • 2854564 Messaging Records Management 2.0 policy can’t be applied in an Exchange Server 2010 environment
    • 2855083 Public Folder contents are not replicated successfully from Exchange Server 2003 or Exchange Server 2007 to Exchange Server 2010
    • 2859596 Event ID 4999 when you use a disclaimer transport rule in an environment that has Update Rollup 1 for Exchange Server 2010 SP3 installed
    • 2860037 iOS devices cannot synchronize mailboxes in an Exchange Server 2010 environment
    • 2861118 W3wp.exe process for the MSExchangeSyncAppPool application pool crashes in an Exchange Server 2010 SP2 or SP3 environment
    • 2863310 You cannot send an RTF email message that contains an embedded picture to an external recipient in an Exchange Server 2010 SP3 environment
    • 2863473 Users cannot access Outlook mailboxes that connect to a Client Access server array in an Exchange Server 2010 environment
    • 2866913 Outlook prompts to send a response to an additional update even though the response request is disabled in an Exchange Server 2010 environment
    • 2870028 EdgeTransport.exe crashes when an email message without a sender address is sent to an Exchange Server 2010 Hub Transport server
    • 2871758 EdgeTransport.exe process consumes excessive CPU resources on an Exchange Server 2010 Edge Transport server
    • 2873477 All messages are stamped by MRM if a deletion tag in a retention policy is configured in an Exchange Server 2010 environment
In addition to these fixes, this Rollup also includes a fix for the security issue described in Microsoft Security Bulletin MS13-061.
Notes:
  • As of Service Pack 2 Rollup 4, its no longer required to disable/re-enable ForeFront Protection for Exchange using the fscutility to be able to install the Rollup properly. However, if you want to remain in control, you can disable ForeFront before installing the Rollup using fscutility /disable and re-enable it afterwards using fscutility /enable;
  • If you want to speed up the update process for systems without internet access, you can follow the procedure described here to disable publisher’s certificate revocation checking;
  • If you got a DAG and want to properly update the DAG members, check the instructions here;
  • Rollups are cumulative, i.e. they contain fixes released in earlier update Rollups for the same product level (RTM, SP). This means you don’t need to install previous Rollups during a fresh installation but can start with the latest Rollup package.
As with any Hotfix, Rollup or Service Pack, I’d recommend to thoroughly test this rollup in a test and acceptance environment first, prior to implementing it in production.
You can download Exchange 2010 SP3 Rollup 2 here.

Exchange 2010 SP2
For those still on Exchange 2010 SP2, Microsoft released Exchange 2010 SP2 Rollup 7. This Rollup only includes the MS13-061 security fix and raises Exchange 2010 SP2′s version number to 14.2.375.0, can be downloaded here; the related KB article is KB2874216.

Monday, 29 July 2013

Soft Recovery and Hard Recovery in Exchange Server

Recovering a database simply involves restoring database files ad transaction logs from the tape to the disk, and then lettings ESE recover all the data from those files and bring the stores back online. This is hard recovery. We use eseutil /cc to initiate the hard recovery.

During the recovery, the database must be offline. But the information store services must be running.

Soft recovery is an automatic process where Exchange can recover data after an unexpected shutdown such as a computer crash or forced power down.

Dirty transactions in memory just before the crash need to be recovered. The recovery process will happen automatically when the database is remounted. Simply restart Exchange. This is what happens when the store is brought back online:

1.    Database is mounted and ESE sees that its state is set to not consistent
1.    ESE enters soft recovery mode
2.    ESE looks at the checkpoint and starts with the transaction file indicated by the checkpoint. (If the checkpoint is not available, then ESE simply starts with the oldest log file, which will take longer to complete).
3.    ESE reads each transaction from the log files right up to the end. For each transaction ESE will read pages from the database file, compare the dbTime value with the page in the log file, and if the transaction in the log file is newer it will execute the transaction.
4.    When ESE finishes replaying the transactions, it will perform a clean dismount of the database. This causes all transactions in memory to be flushed to the database file, and sets the file state to consistent.
5.    ESE then remounts the database. Because the state is consistent ESE enters normal mode and regular operations can continue.
6.    

We use eseutil /r to initiate the soft recovery.


Eseutil /cc
Performs a hard recovery after a database restore.
Eseutil /d
Performs an offline compaction of a database.
Eseutil /g
Verifies the integrity of a database.
Eseutil /k
Verifies the checksums of a database.
Eseutil /m
Generates formatted output of various database file types. e.g. /mh
Eseutil /p
Repairs a corrupted or damaged database.
Eseutil /r
Performs soft recovery to bring a single database into a consistent or clean shutdown state.
Eseutil /y
Copies a database, streaming file, or log file.

White Space in Exchange 2010

When items are removed from the Exchange database, the space that is freed up in the database is called white space. Exchange will use the available white space in its database for new database content before having to grow the size of the database.

With Exchange 2007 and older versions, one of the key elements that an Exchange administrator needed to keep an eye on, and caused confusion for newcomers to Exchange was the amount of white space in the database.
This is reported as free space in the event viewer via event ID 1221 during the night and is the result of content being removed from the database by the online maintenance process.
With Exchange 2010, the behavior of the database has changed.
Instead of performing an online maintenance during a fixed time window, it now does it constantly. This means that content that has passed the deleted item retention period, is removed from the database shortly afterwards, rather than waiting for the next online defrag window.

However because the process is running constantly, event ID 1221 isn’t written to the event log. Therefore an administrator may not have a clue as to how much of the database is white space, and how much is actual content.

This question can be easily answered, using EMS, as the amount of free space in the database is available via get-mailboxdatabase -Status:

Get-MailboxDatabase -Status | Select Servername, Name, AvailableNewMailboxSpace

This command will show you the name of the Server the database is mounted on, the name of the database (which is unique across the Exchange org with Exchange 2010) and the amount of space available in the database for new content.
The result will be something along the lines of this:

ServerName         Name Available            NewMailboxSpace
————–            ——————–            ————————
EXCH10       Mailbox Database        27.75 MB (29,097,984 bytes)

The command used get-mailboxdatabase -status can provide quite a bit of information about the databases in your Exchange org, use the |fl command to see the full list.

Always remember that when you perform stress testing/sizing for your Exchange 2010 environment, the IOPS created by this online maintenance should be kept in mind. Jetstress is a tool to play with.

In Earlier versions of Exchange, admins used to run the switch eseutil /d for offline defragmentation on exchange databases.

To know this better, we need to discuss about event id: 1221 and its relevance.

Event Type:        Information
Event Source:    MSExchangeIS Mailbox Store
Event Category:                General
Event ID:              1221
Date:     01/01/2005
Time:     00:04:16
User:     N/A
Computer:          SERVER
Description:        The database “First Storage Group\Mailbox Store (SERVER)” has 3.4 megabytes of free space after online defragmentation has terminated.

Exchange has performed a routine maintenance and any old data that is past the delete thresholds has been deleted from the database.
The space it has left behind has then been converted into “white space”. No difference in the size of the database.
This “white space” will be used by Exchange, before expanding the database any larger


Online defragmentation is an automated defragmentation process as a part of its scheduled maintenance which we specify on a mailbox store level in ESM where the actual database size remains the same wherein Offline defragmentation is the process we use to shrink the database size removing white spaces using the eseutil /d switch.

To determine the whitespace using eseutil command by using eseutil /ms

Refer 1 2

Personal Archive and Online Archive in Exchange 2010

Personal Archive:
In Microsoft Exchange Server 2010, personal archives provide users an alternative storage location in which to store historical messaging data. A personal archive is an additional mailbox (called an archive mailbox) enabled for a mailbox user. Outlook 2010, Outlook 2007, and Outlook Web App users have seamless access to their archive mailbox. By using either of these client applications, users can view an archive mailbox and move or copy messages between their primary mailbox and the archive. Personal archives present a consistent view of messaging data to users, and eliminate the user overhead required to manage .pst files. 

In Exchange 2010 Service Pack 1 (SP1), you can provision a user's personal archive on the same mailbox database as the user's primary mailbox, another mailbox database on the same Mailbox server, or a mailbox database on another Mailbox server in either the same or another Active Directory site. This provides flexibility to use tiered storage architecture and to store archive mailboxes on a different storage subsystem, such as near-line storage. In cross-premises Exchange 2010 deployments, you can also provision a cloud-based archive for mailboxes located on your on-premises Mailbox servers.

Provisioning archive mailboxes

Online Archive:
Microsoft Exchange Online Archiving is a cloud-based, enterprise-class archiving solution for your Exchange Server 2010 Service Pack 1 (SP1) or later on-premises organization. With Exchange Online Archiving, your organization can host your users’ primary mailboxes on your on-premises servers and store their historical e-mail data in cloud-based archive mailboxes. This solution can assist your organization with archiving, compliance, regulatory, and e-discovery challenges, while simplifying your on-premises infrastructure. EOA provides you the following advantages:

Help meet long-term retention requirements Cloud-based archives allow you to store large quantities of messaging data off-site in secure and controlled datacenters. Exchange Online Archiving helps your organization meet regulatory compliance or business requirements for long-term retention of e-mail. Using archive policies, messages are moved from on-premises mailboxes to the cloud-based archives. The same retention policies applied to on-premises mailboxes can be enforced on cloud-based archives.

Help meet eDiscovery and litigation hold requirements With cloud-based archives for your on-premises mailbox users, you can perform seamless discovery searches across both the on-premises primary mailbox and the cloud-based archive. When users are placed on litigation hold in your on-premises organization, their cloud-based archive is also placed on hold.

Lower storage costs Moving historical e-mail data to a cloud-based archive allows you to reduce your organization’s storage requirements. You can provision users’ primary mailboxes with appropriate mailbox quotas, which keeps mailbox sizes in control and your storage costs low.

Provide Anywhere Access Cloud-based archive mailboxes are similar to an on-premises archive mailbox. Using Outlook 2010, Outlook 2007 or Outlook Web App, users are able to access older messages and content in the archive transparently, without requiring any additional configuration on their computers.

Note: Outlook users can access an archive mailbox in online mode. Archive mailboxes aren’t cached to the user's computer when using Outlook in Cached Exchange Mode

Wednesday, 10 July 2013

How to get the EAS report

PS C:\Windows\system32> get-casmailbox -resultsize unlimited | where{$_.hasactivesyncdevicepartnership -eq "TRUE"} | foreach-object{Get-ActiveSyncDeviceStatistics -Mailbox $_.name} | Select Identity, FirstSyncTime, LastSyncAttemptTime, LastSuccessSync, DeviceType, DeviceID, DeviceUserAgent, DeviceModel, DeviceOS, DeviceAccessState, DeviceAccessStateReason,
DevicePolicyApplied, DevicePolicyApplicationStatus, DeviceActiveSyncVersion | Export-Csv C:\temp\asdevices.csv

Thursday, 20 June 2013

How email flows in Exchange 2010

In Exchange 2010, all messages are always routed through the Hub Transport Server.

Mail Submission Service – when a message is created and the Send button is clicked, the new message is placed in the mailbox outbox. There’s a service running on the Mailbox Server role called the “Exchange Mail Submission Service” which notifies the Hub Transport Server that a new message is awaiting for processing. The Mailbox Server has an internal list of Hub Transport Servers in the same Active Directory site (the submission server list) which is updated every 10 minutes. This is done by the server discovery process. A round robin mechanism is responsible for load balancing the SMTP traffic across these Hub Transport Servers

Store Drivers – the Hub Transport Server’s Store Driver retrieves the message from the Outbox and puts it in the Submission Queue on the Hub Transport Server. The Store Driver uses RPC to retrieve the message from the Mailbox Server. There’s no traffic on port 25 (i.e. SMTP) between the Hub Transport Server and the Mailbox Server.

Submission Queue – this is a queue, located on the Hub Transport Server where all messages are stored that need to be processed. Not only the Store drivers can store messages in the submission queue, but this can also be done through a receive connector or the pickup directory.

Categorizer – the categorizer retrieves messages from the submission queue and determines where the message needs to be sent to. This can be an internal Active Directory recipient or an external recipient. The categorizer also expands distribution groups and identifies alternative recipients or forwarding addresses.

Pickup Directory – this is a directory that is checked once every 5 seconds for new messages. When a message is in the correct EML format it is picked up from this directory and when the process is completed the file is deleted from the pickup directory.

Sunday, 16 June 2013

Transport Dumpster and Shadow Redundancy, why both?

Transport dumpster is a feature built into Exchange Server 2010 HUB transport role and designed to minimize data loss during mail delivery to a DAG in a lossy failover scenario. The transport dumpster is stored inside the mail.que file. It's only available for message delivery in a cluster continuous replication (CCR) environment and doesn't address potential message loss when messages are in transit between Hub Transport and Edge Transport servers.

With shadow redundancy, the deletion of a message from the transport databases is delayed until the transport server verifies that all of the next hops for that message have completed delivery. If any of the next hops fail before reporting back successful delivery, the message is resubmitted for delivery to that next hop.

Understanding Shadow Redundancy
http://technet.microsoft.com/en-us/library/dd351027.aspx

Shadow Redundancy Mail Flow Scenarios
http://technet.microsoft.com/en-us/library/dd351091.aspx

For Dumpster: The recommendation is that this be set to 1.5 times the maximum message size limit within your environment. The default value for this setting is 18 MB.
By default, shadow messages are discarded automatically after two days.

Configure Shadow Redundancy
http://technet.microsoft.com/en-us/library/dd351046.aspx