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

Friday, October 8, 2010

Bulk Create Exchange 2010 Databases

By:Rik Hoffelder


Here's a handy script I wrote to bulk create mailbox databases to follow a strict naming convention and consistent configuration. It was designed to work with Exchange 2010, however it works just as well with 2007. The intent is to help organizations maintain consistency using a simple process that can be performed by less skilled administrators.


Script itself uses several command line parameters to create the variables needed for the scripts. The following provides the script usage:


.\createdbs.ps1 2010Server NumberOfDatabases DatabaseStartNumber DatabaseDrive LogDrive WarningQuota SendQuota SendReceiveQuota DeletedItemRetention MailboxRetention Oab PfDb

The following is an example of proper usage:

.\CreateDbs.PS1 EX2010 4 1 E D 450MB 500MB Unlimited 30 14 "\Default Offline Address List" "Public Folder Database 1"

In the above example 4 databases are created on server EX2010 with the following names:

EX2010-DB01-0500
EX2010-DB02-0500
EX2010-DB03-0500
EX2010-DB04-0500

The database are created on drive E, with the log files on drive D. The mailbox store is set to issue size limit warnings at 450MB, prohibit send at 500MB, and prohibit send/receive is set to unlimited. Next deleted items are retained for 30 days, while deleted mailboxes are retained for 14. Finally the Offline Address book is set along with the public folder database used by each mailbox store.

So let's suppose we need to create 3 more databases, but this time on drive G, with the logs on drive H. Let's also set the mailbox size limit to 1GB. You would run the following:

.\CreateDbs.PS1 EX2010 3 5 G H 900MB 1GB 2GB 10 7 "\North America OAB" "Public Folder Database 2"

This would have created databases EX2010-DB05-1000, EX2010-DB06-1000, and EX2010-DB07-1000 with 10 day deleted item retention, 7 day delete mailbox retention, a warning limit of 900MB, prohibit send at 1GB and prohibit send/receive at 2 GB. The OAB would be set to North America OAB and use Public Folder Database 2.

Notice how the DBxx value began with DB05 and the last four digits are now 1000.
The DbStartNum parameter determine the beginning of the numbering scheme in the DBxx portion. The -XXXX at the end uses the ProhibitSend value to represent the mailbox send size limit, making it easy for administrators to identify where to place mailboxes by the database name. A size limit of 125MB would produce a name SERVER-DBXX-0125 and so forth.

It's simple and flexible. To run it simply copy it to a PS1 file then lanuch it from Exchange Management Shell.

CreateDatabases.PS1

### BEGIN SCRIPT ###
Param(
[string] $2010Server = "",
[decimal] $NumDatabases = "",
[decimal] $DbStartNum = "",
[string] $DbDrive = "",
[string] $LogDrive = "",
[string] $WarnQuota = "",
[string] $SendQuota = "",
[string] $SendReceiveQuota = "",
[string] $DeletedItemRetention = "",
[string] $MailboxRetention = "",
[string] $OAB = "",
[string] $PfDb = ""
)

# This function validates the scripts parameters
function ValidateParams
{
$validInputs = $true
$errorString = ""
if ($2010Server -eq "")
{
$validInputs = $false
$errorString += "`nMissing parameter: The 2010Server parameter is required. Please enter the name of the Exchange 2010 server to configure. Example KCCEX2010"
}
if ($NumDatabases -eq "")
{
$validInputs = $false
$errorString += "`nMissing parameter: The NumDatabases parameter is required. Please enter the number of mailbox databases that will be created on this Exchange 2010 server. Example 8."
}
if ($DbStartNum -eq "")
{
$validInputs = $false
$errorString += "`nMissing parameter: The DbStartNum parameter is required. Please enter the starting database number. Example 5."
}
if ($DbDrive -eq "")
{
$validInputs = $false
$errorString += "`nMissing parameter: The DbDrive parameter is required. Please enter the drive letter on which you will create mailbox databases. Example: E"
}
if ($LogDrive -eq "")
{
$validInputs = $false
$errorString += "`nMissing parameter: The LogDrive parameter is required. Please enter the drive letter on which you will create transaction logs. Example: D"
}
if ($WarnQuota -eq "")
{
$validInputs = $false
$errorString += "`nMissing parameter: The WarnQuota parameter is required. Please enter the vaule to issue mailbox size limit warning. Example: 450MB or 1.5GB"
}
if ($SendQuota -eq "")
{
$validInputs = $false
$errorString += "`nMissing parameter: The SendQuota parameter is required. Please enter the vaule to issue mailbox size limit exceeded. Example: 500MB or 1GB"
}
if ($SendReceiveQuota -eq "")
{
$validInputs = $false
$errorString += "`nMissing parameter: The SendReceiveQuota parameter is required. Please enter the vaule at which the mailbox stops accepting mail. Example: Unlimited or 550MB"
}

if ($DeletedItemRetention -eq "")
{
$validInputs = $false
$errorString += "`nMissing parameter: The DeletedItemRetention parameter is required. Please enter the vaule in days. Example: 14"
}
if ($MailboxRetention -eq "")
{
$validInputs = $false
$errorString += "`nMissing parameter: The MailboxRetention parameter is required. Please enter the vaule in days. Example: 30"
}
if ($OAB -eq "")
{
$validInputs = $false
$errorString += "`nMissing parameter: The OAB parameter is required. Please enter the name of the offline address list to be used by this mailbox database in quotes. Example: 'Corporate OAB' "
}
if ($PfDb -eq "")
{
$validInputs = $false
$errorString += "`nMissing parameter: The PfDb parameter is required. Please enter the name of the public folder database in quotes. Example: 'Pub Folders DB 1'"
}

if (!$validInputs)
{
Write-error "$errorString"
}
return $validInputs
}


### Validate the parameters ###
$ifValidParams = ValidateParams;

if (!$ifValidParams) { exit; }

### Define Script variables ###
$2010Server = $2010Server.ToUpper()
$b = $NumDatabases + $DbStartNum
$DeletedItemRetention = $DeletedItemRetention + ".00:00:00"
$MailboxRetention = $MailboxRetention + ".00:00:00"

$SendQuotaLen = $SendQuota.Length
$DBSize = $SendQuotaLen - 2
[decimal] $DBSizeNum = $SendQuota.substring(0,$DBSize)

If ($DbSizeNum -le 9) {$DbExName = [string] $DbSizeNum + "000"}
ElseIf ($DbSizeNum -ge 10 -and $DbSizeNum -le 99) {$DbExName = "00" + $DbSizeNum}
ElseIf ($DbSizeNum -ge 100) {$DbExName = "0" + $DbSizeNum}

If ($DbStartNum -gt 9) {$MdbName = $2010Server + "-DB" + $DbStartNum + "-" + $DbExName}
Else {$MdbName = $2010Server + "-DB0" + $DbStartNum + "-" + $DbExName}
$EdbFilePath = $DbDrive + ":\Exchange\Databases\" + $MdbName + "\" + $MdbName + ".EDB"
$LogFolderPath = $LogDrive + ":\Exchange\Logs\" + $MdbName
$MdbID = $2010Server + "\" + $MdbName

### Create Mailbox Databases Loop ###
Do {New-MailboxDatabase -Name $MdbName -Server $2010Server -EdbFilePath $EdbFilePath -LogFolderPath $LogFolderPath -OfflineAddressBook $OAB -PublicFolderDatabase $PfDb
;Mount-Database $MdbName
;Set-MailboxDatabase –Identity $MdbName –IssueWarningQuota $WarnQuota –ProhibitSendQuota $Sendquota –ProhibitSendReceiveQuota $SendReceiveQuota -DeletedItemRetention $DeletedItemRetention -MailboxRetention $MailboxRetention -RetainDeletedItemsUntilBackup $True
;$DbStartNum++
;If ($DbStartNum -gt 9) {$MdbName = $2010Server + "-DB" + $DbStartNum + "-" + $DbExName}
Else {$MdbName = $2010Server + "-DB0" + $DbStartNum + "-" + $DbExName}
;$EdbFilePath = $DbDrive + ":\Exchange\Databases\" + $MdbName + "\" + $MdbName + ".EDB"
;$LogFolderPath = $LogDrive + ":\Exchange\Logs\" + $MdbName
;$MdbID = $2010Server + "\" + $MdbName
}
Until ($DbStartNum -eq $b)
### END SCRIPT ###






More information on Exchange




Read more!

Thursday, June 3, 2010

Exchange 2007 Rollup Causes “Outlook Web Access was unable to initialize” errors

By:Rik Hoffelder
If you’re reading this chances are you have applied a rollup to Exchange 2007. In my case it was Rollup 4 for Exchange 2007 SP2. After applying the update OWA users began experiencing errors accessing the login page stating “Outlook Web Access was unable to initialize. Contact your administrator.”

When this occurred MSExchangeOWA wrote a FormsRegistry error with Event ID 4 into that application log. Specifically it stated the “More than one forms registry is named Premium” as shown below.



After researching the problem on the web and finding nothing I did a little investigating and found the problem to be a simple case of an installer not cleaning up after itself. In this case a directory named Copy of premium existed in the same sub-directory as the premium directory. This is typically located under C:\Program Files\Microsoft\Exchange Server\ClientAccess\Owa\forms.



To resolve the problem I simply deleted the Copy of premium directory then ran IISRESET /NOFORCE. This resolved the issue in my case. I can’t say it will work for everyone, but since there is very little information about this error anywhere, I thought I would share at least one solution.





More information on Exchange




Read more!

Friday, November 20, 2009

Mailbox Reporter for Exchange 2007 & 2010

By:Rik Hoffelder
Exchange 2007 and 2010 brought about many great new features and functions. However Microsoft forgot about the little guy when it came to getting a quick overview of mailbox statistics via a GUI. It really made quite a few of my customers unhappy. It’s not that Exchange 2007 or 2010 do not provide this information, it is only available on individual mailbox properties in the Exchange Management Console, you cannot view all mailboxes on a given store without using the Get-MailboxStatistics cmdlet then piping the output to a file.

While this is all well and good, most Exchange Admins moving from 2000 or 2003 to 2007 aren’t familiar with PowerShell, let alone Exchange Management Shell. As a result I wrote this handy little script to replace that functionality and view all mailboxes within the organization. It’s run from Exchange Management Shell using the following command:

C:\Scripts> ./MailboxReport.PS1

It then opens the report in a web browser as shown below:



Just copy the code below and paste into a text file named MailboxReport.PS1 then run as described above. It works with Exchange 2007 or Exchange 2010. I hope you find it useful!

#Exchange Mailbox Reporter
$a = "<style>"
$a = $a + "BODY{background-color:white;}"
$a = $a + "TABLE{border-width: 1px;border-style: solid;border-color: black;border-collapse: collapse;}"
$a = $a + "TH{border-width: 1px;padding: 0px;border-style: solid;border-color: black;background-color:LightBlue}"
$a = $a + "TD{border-width: 1px;padding: 0px;border-style: solid;border-color: black;background-color:White}"
$a = $a + "</style>"
$b = "<H2> Mailbox Summary Report </H2>"
$servers = get-mailboxserver
Foreach ($server in $servers) {
Get-MailboxStatistics -server $Server |
Where-Object {$_.DisplayName -NotMatch "^CAS_"} |
Where-Object {$_.DisplayName -NotMatch "^SystemMailbox"} |
Where-Object {$_.DisplayName -NotMatch "^Microsoft System"} |
Select-Object DisplayName, ItemCount, TotalItemSize, StorageLimitStatus, LastLogonTime, LastLogoffTime, LastLoggedOnUserAccount, ServerName, Database |
Sort-Object TotalItemSize -descending |
ConvertTo-HTML -head $a -body $b |
Out-File MailboxReport.htm
}
Invoke-Expression ./MailboxReport.htm







More information on Exchange


Read more!

Wednesday, November 18, 2009

Quick Exchange 2007 Server Status

By:Rik Hoffelder
Over the past few years I have accumulated several time saver and management scripts for Exchange 2007 using the Exchange Management Shell. I thought I would begin sharing some of the more generic and useful scripts. This particular script collects data from various performance counters and runs several Exchange 2007’s Test- cmdlets. It then writes the data to a HTM file and opens with the results.

The script must be run from under Exchange Management Shell and is intended to run against one server. I’ll post another version that collects from multiple servers; however it has been my experience that if you have multiple Exchange servers, you probably already have a monitoring solution. This was written from my Mom & Pop customers would need a quick, yet free, monitoring method. It offers no alerting, just basic information.

To run, simply copy and paste the following into a text file named ExchangeReport.PS1 then launch it from Exchange Management Shell by running the following command:

C:\Scripts> ./ExchangeReport.PS1

After running the code the Report.HTM file will open and present several items in tables as shown below:


Code Sample:
$a = "<style>"
$a = $a + "BODY{background-color:white;}"
$a = $a + "TABLE{border-width: 1px;border-style: solid;border-color: black;border-collapse: collapse;}"
$a = $a + "TH{border-width: 1px;padding: 0px;border-style: solid;border-color: black;background-color:LightBlue}"
$a = $a + "TD{border-width: 1px;padding: 0px;border-style: solid;border-color: black;background-color:White}"
$a = $a + "</style>"

Get-ExchangeServer | Select-Object Name, AdminDisplayVersion, ServerRole, IsMemberofCluster | ConvertTo-HTML -head $a -body "<H2>Exchange Server Information</H2>" | Out-File Report.htm

Get-WmiObject Win32_service -errorAction silentlyContinue | Where-Object {$_.name -match "^msexchange."} |
select-object Name, Status ConvertTo-HTML -head $a -body "<H2>Exchange Services State</H2>" |
Out-File Report.htm -Append

Get-Queue | Select-Object Identity, MessageCount, Status, DeliveryType, NextHopDomain, LastError |
ConvertTo-HTML -head $a -body "<H2>Message Queues</H2>" |
Out-File Report.htm -Append

Get-WmiObject -query "select * from Win32_PerfFormattedData_MSExchangeTransportQueues_MSExchangeTransportQueues" |
select-object Name, ActiveRemoteDeliveryQueueLength, ActiveMailboxDeliveryQueueLength, SubmissionQueueLength, RetryMailboxDeliveryQueueLength |
ConvertTo-HTML -head $a -body "<H2>Message Queue Counters</H2>" |
Out-File Report.htm -Append

Get-WmiObject -errorAction silentlyContinue -query "Select * from Win32_PerfFormattedData_MSExchangeTransportSmtpSend_MSExchangeTransportSmtpSend" |
Select-Object MessageBytesSentPersec, MessageBytesSentTotal, MessagesSentPersec, MessagesSentTotal |
ConvertTo-HTML -head $a -body "<H2>SMTP Counters</H2>" |
Out-File Report.htm -Append

Get-WmiObject -errorAction silentlyContinue -query "Select * from Win32_PerfFormattedData_MSExchangeIS_MSExchangeIS" |
Select-Object ActiveUserCount, ActiveConnectionCount, ConnectionCount, RPCRequests, RPCPacketsPersec, RPCOperationsPersec, WriteBytesRPCClientsPersec, RPCAveragedLatency |
ConvertTo-HTML -head $a -body "<H2>Information Store Counters</H2>" |
Out-File Report.htm -Append

Get-WmiObject -errorAction silentlyContinue -query "Select * from Win32_PerfFormattedData_MSExchangeIS_MSExchangeISMailbox" |
Select-Object ClientLogons, ActiveClientLogons, MessageOpensPersec, FolderOpensPersec, AverageDeliveryTime, MessagesDeliveredPerSec, MessagesSentPersec, ReceiveQueueSize, MessagesQueuedForSubmission |
ConvertTo-HTML -head $a -body "<H2>Mailbox Store Counters</H2>" |
Out-File Report.htm -Append

Test-MAPIConnectivity | Select-Object Server, Database, Result, Latency, Error |
ConvertTo-HTML -head $a -body "<H2>MAPI Connectivity</H2>" |
Out-File Report.htm -Append

Test-OWAConnectivity | Select-Object ClientAccessServer, MailboxServer, URL, Scenario, Result, Latency, Error |
ConvertTo-HTML -head $a -body "<H2>OWA Connectivity</H2>" |
Out-File Report.htm -Append

Test-ActiveSyncConnectivity | Select-Object ClientAccessServer, MailboxServer, Scenario, Result, Latency, Error |
ConvertTo-HTML -head $a -body "<H2>ActiveSync Connectivity</H2>" |
Out-File Report.htm -Append

Test-MailFlow | Select-Object TestMailFlowResult, MessageLatencyTime, IsRemoteTest |
ConvertTo-HTML -head $a -body "<H2>Mail Flow</H2>" |
Out-File Report.htm -Append

Test-OutlookWebServices | Select-Object Id, Type, Message |
ConvertTo-HTML -head $a -body "<H2>Exchange Web Services</H2>" |
Out-File Report.htm -Append

Invoke-Expression Report.htm
#---End of Code Sample---


More information on Exchange


Read more!

Thursday, October 22, 2009

Is Brick-level Necessary for Exchange?

By:Rik Hoffelder

The need for brick-level backup of Exchange mailboxes is often a topic of discussion with customers. This is of particular concern to those with large message stores, short backup windows, and demanding users. In my opinion Exchange provides enough out of the box functionality that brick-level backups are really unnecessary in all but the most crucial of mailboxes. You know the mailbox that belongs to the person who signs your paycheck! In all seriousness I feel brick-level backup is mostly a waste of tape and/or disk.


Let's first take into consideration the deleted items retention configuration on mailbox stores; a feature that has been with Exchange through many generations. This feature marks a deleted message as hidden to the database thus places it in a "dumpster." By deleted message I mean a message that has been purged from the mailbox, not left in the Deleted Items folder. The length of time the message remains in the dumpster is determined by the deleted items retention configuration on the message store. A value greater than zero will keep the message hidden for that many days, after which time the database page(s) are marked for reuse in effect purging the message from the database. However during the time the message is in the dumpster it is recoverable.
Many of you may already be familiar with the Recover Deleted Items function under Outlook's Tools menu. By default this menu option is grayed out unless you have selected the Deleted Items folder. Microsoft has a little known knowledge base article that documents a registry setting allowing the Deleted Items Recovery option to be available to all folders, not just Deleted Items. This setting not only allows recovery from all folders within the mailbox but all public folders as well. The public folder store also has a deleted items retention configuration. (Additional information on this registry setting can be found in How can I recover items that I have "hard deleted" in Outlook? )

Deleted Item Recovery using this method not only has the benefit of being able to recover any message from any folder; you can also recover messages that have been hard deleted when someone uses SHIFT+DELETE. As a result you can recover messages that have been delivered after the last backup, eliminating the data loss a SHIFT+DELETE would present using brick-level restore. Additionally all recovery is done online, you never need to mount a tape so it literally takes seconds to locate and restore messages. But wait there's more; you can configure this for all end users so they can recover their own messages never having to wait hours, even days for recovery. Do you think that can reduce admin overhead and help desk calls for those little uh-ohs?

Yes there are a few gotchas, what did you expect for out-of-the-box? For instance, each mailbox or public folder store is limited to 4 GBs of dumpster space within the database. For large message stores this will reduce the amount of time you can keep deleted items before reaching the limit. If you exceed the 4 GB limit messages are purged on a First In - First Out (FIFO) basis. It has been my experience that a 100GB mailbox store under normal utilization can support up to 14 days worth deleted items comfortably. This obviously varies by environment; fortunately Microsoft took some the guess work out. Exchange 5.5 Server or later include performance counters under the Information Store object that show current dumpster utilization.

So how do I handle a case where the message is past the recovery period? This is where the Recovery Storage Group comes into use. First introduced in Exchange Server 2003 the RSG allows you to perform an online restore of mailbox databases to a separate storage group and mailbox store instance, then merge the data with the on-line mailbox. Again this is not a perfect solution as the active mailbox must reside on the same server that the backup was taken from. In other words if I moved the mailbox to a different store since the backup I wish to restore was taken, I need to move the mailbox back in order to merge the data. This is very well detailed in Microsoft's knowledge base article How to use Recovery Storage Groups in Exchange Server 2003. The other issue is that the original user account must exist in Active Directory, if this has been deleted you cannot use a RSG. However you can follow the steps I outline in my blog posting How to Build an Exchange 2003 Disaster Recovery Server.


More information on Exchange


Read more!

Wednesday, August 26, 2009

Exchange 2007 SP2 is Here!

By:Rik Hoffelder
Microsoft released Service Pack 2 for Exchange 2007 this week with little fanfare, so I thought it would be nice to start the article this way. Why am I excited? A few reasons actually, first it means Exchange 2010 is just around the corner; hopefully in time for Christmas. Second is that it adds a few of those "it's about time" features such as a plug-in for Windows 2008 Backup. Sure that isn't important to most of you, but for lab environments and training purposes this is a finally nice to have..

The plug-in is based on a new executable, WSBExchange.exe, which is installed automatically on Exchange 2007 Mailbox Servers running on Windows 2008. There are a few items to be aware of, first it only supports VSS backups, no streaming ESE support, which Windows 2008 Backup doesn't support anyway. Exchange backups are only supported on the local server; you cannot backup remote mailbox servers like you could in the 2003 days.

You can only perform full storage group backups, incremental backups are not available. You can back to either a local or network drive though. Committed logs are still flushed at the end of the job. But you can't restore a single database or storage group; you have to restore the whole thing. A feature I wish they would have spent a little more time on, ad-hoc incremental backups during mailbox migrations was always a plus if your short on log drive and long on mailbox data.

While it does have its limitations, it is still a useful tool for lab and training environments. After all the best time to learn Exchange database recovery is not when you have a production failure.!
So what else do I like? How about more refined mailbox and folder auditing? SP 2 offers these new access auditing enhancements that are beneficial to those in regulated industries.
  • The Folder Access category lets you log events that correspond to opening folders, such as the Inbox, Outbox, or Sent Items folders.
  • The Message Access category lets you log events that correspond to explicitly opening messages.
  • The Extended Send As category lets you log events that correspond to sending a message as a mailbox-enabled user.
  • The Extended Send On Behalf Of category lets you log events that correspond to sending a message on behalf of a mailbox-enabled user.
For those even more security conscience you can collect and store this data using System Center Operations Manager Audit Collection Services to maintain access records along with retained e-mail. Yes a bit big brother, but if it's your job is on the line, would you like proof someone else sent the message? How about if someone was posting messages directly in another mailbox to bypass journaling? I have seen it happen; now I can prove it!
Okay so there isn't a heck of lot in there but what did you expect with 2010 just around the corner?


More information on Exchange

Read more!
Microsoft Virtualization, Citrix, XENServer, Storage, iscsi, Exchange, Virtual Desktops, XENDesktop, APPSense, Netscaler, Virtual Storage, VM, Unified Comminications, Cisco, Server Virtualization, Thin client, Server Based Computing, SBC, Application Delivery controllers, System Center, SCCM, SCVMM, SCOM, VMware, VSphere, Virtual Storage, Cloud Computing, Provisioning Server, Hypervisor, Client Hypervisor.