Preparing an Exchange 2010 DAG DR server

*N.B. this is an old article and may no longer be relevant*

Consider this scenario. You want to add an additional Exchange 2010 mailbox server that is going to be part of a DAG but you don’t want it to have any primary mailbox database copies e.g. a DR server that is only going to have database copies of activation preference 3

During installation you are forced to create a mailbox database. So here’s a simple way of achieving the goal.

My command to install the mailbox node is this:

C:\Installs\ExchangeMedia\Setup.com /mode:Install /Role:M /TargetDir:D:\Exchange /u:C:\Installs\ExchangeMedia\Updates /InstallWindowsComponents /MdbName:DefunctDB /DbFilePath:C:\Installs\DefunctDB.edb /LogFolderPath:C:\Installs

My command to tidy up the database and files after a reboot is this:

Remove-MailboxDatabase DefunctDB -Confirm:$false; del C:\installs\*.log; del c:\installs\*.edb; del c:\installs\*.jrs; del C:\installs\*.chk

Now you have a nice tidy mailbox server to add to your DAG and replicate mailbox databases to.

Exchange 2010 First Public Folder Database

*N.B. this is an old article and may no longer be relevant*

The first Public Folder Database in Exchange 2010 gets assigned a random name and installed at the default location. This may be okay for many customers, but not most. So a bit of tidy up work is required. Fortunately Captain Powershell has it under control.

Get-PublicFolderDatabase -Server SERVER1 | Set-PublicFolderDatabase -Name PFDB01 ; Dismount-Database PFDB01 -Confirm:$false ; Move-DatabasePath PFDB01 -edbFilePath M:\ExchangeData\PFDB01\PFDB01.edb -LogFolderPath L:\ExchangeData\PFDB01LOGS -Confirm:$false ; Mount-DataBase PFDB01

(where SERVER1 is the name of the first mailbox server built into the environment)

Here’s my job log:

[PS] C:\Windows\system32>Get-PublicFolderDatabase

Name Server
---- ------
Public Folder Database 1399... SERVER1

[PS] C:\Windows\system32>Get-PublicFolderDatabase -Server SERVER1 | Set-PublicFolderDatabase -Name PFDB01 ; Dismount-Database PFDB01 -Confirm:$false ; Move-DatabasePath PFDB01 -edbFilePath M:\ExchangeData\PFDB01\PFDB01.edb -LogFolderPath L:\ExchangeData\PFDB01LOGS -Confirm:$false; Mount-DataBase PFDB01

[PS] C:\Windows\system32>Get-PublicFolderDatabase

Name Server
---- ------
PFDB01 SERVER1


I think the only way to improve on it would be to tidy up the empty folder left behind, but I’m not going to lose sleep over that.

MS Exchange RPC Client Access Service fails to start

*N.B. this is an old article and may no longer be relevant*

I had an issue with installing Exchange 2010 whereby installation took an age and the MS Exchange RPC Client Access service failed to start. I’ve had a similar issue in the past with DoubleTake, so applied the same troubleshooting and workaround.

To troubleshoot, I established that the MS Exchange RPC Client Access service is trying to listen on a particular port, so looked to see why that might not be able to. Firewall off, start MSExchangeRPC service – fail. Check for other software installed – (no AV) – the only other software is some asset management software called NetSupportDNA. Found the service for that, stopped the service, start MSExchangeRPC service – success, start NetSupportDNA service – success. Modified the service startup type for NetSupportDNA service to Automatic (delayed start) and for good measure added a dependency on the MSExchangeRPC service (new multistringvalue in regedit). A small screen capture is included at the end of this post.

During further Exchange server installations I’ll stop the NetSupportDNA service (it doesn’t need to be running all the time) and then modify the parameters before a server reboot (I exported the registry key and whittled it down to these two items).

The client finds this an acceptable workaround. I’ll need to do it on the mailbox servers as well as clients connect directly to them for Public Folders.

While this is a fairly specific problem, as I said at the beginning, I came across a similar issue previously so I’m really just highlighting the delayed start service startup type and how it can be used to workaround issues.

BES links (re: Exchange)

*N.B. this is an old article and may no longer be relevant*

I've compiled all the BES links that an Exchange Consultant could possibly want. If I've missed anything, then you're over-engineering it.

BlackBerry Enterprise Server Compatibility Matrix - http://btsc.webapps.blackberry.com/btsc/viewdocument.do?noCount=true&externalId=KB22601

Recommended Microsoft Active Directory groups for the BlackBerry Enterprise Server service account – KB04557 - http://btsc.webapps.blackberry.com/btsc/viewdocument.do?externalId=KB12309

Some BlackBerry smartphone users are unable to receive emails after a mailbox move from Exchange 2007 to Exchange 2010 – KB32634 - http://btsc.webapps.blackberry.com/btsc/viewdocument.do?noCount=true&externalId=KB32539

How to install or upgrade the MAPI Client and Collaboration Data Objects 1.2.1 on the BlackBerry Enterprise Server – KB15779 - http://btsc.webapps.blackberry.com/btsc/viewdocument.do?externalId=KB10285

Restarting the BlackBerry Enterprise Server services may cause delays in message delivery – KB04789 - http://btsc.webapps.blackberry.com/btsc/viewdocument.do?externalId=KB03296

How to turn ON Global Catalog referrals on BlackBerry Enterprise server – KB16118 - http://technet.microsoft.com/en-us/library/ee332346.aspx

Search the Blackberry Knowledge Base - http://btsc.webapps.blackberry.com/btsc/microsites/microsite.do

I'm aware that RIM have (in the past) moved or deleted their KB articles. To this end I have created some very basic pdfs of the above articles and packed them in one zip file. You can download the zip file here. Wasn't that nice of me?

Fixing Failed and Suspended DB copies

*N.B. this is an old article and may no longer be relevant*

I was looking for something in my archive e-mail and stumbled across this script for Exchange 2010.

One of the things I have observed is that database copies easily fail if you have repeated failovers and switchovers with little or no traffic. As what happens when you are testing a new environment.

http://www.cohesivelogic.com/2010/08/automatically-fixing-failedandsuspended-exchange-2010-databases-with-powershell/

It's not one of my scripts, so I'm not taking credit for it.

Here is the script listed in the article:



add-pssnapin *0* -ErrorAction SilentlyContinue
$startstring="Start script run at:  "
$startendtime=date
$startannounce=$startstring+$startendtime
Start-Transcript -Append -Force -Path 'C:\<path>\DBHealthFix.log'
$startannounce
#gets list of mailboxservers, locates 2010 servers, gets db copy status, finds copies that are failed, updates failed copies
$mailboxservers = get-mailboxserver | get-exchangeserver | ?{$_.IsE14OrLater -eq 'True'}
foreach ($mailboxserver in $mailboxservers){
get-mailboxdatabasecopystatus -Server $mailboxserver.name | ?{$_.Status -like 'FailedAndSuspended'} | update-mailboxdatabasecopy -deleteexistingfiles -confirm:$false
}
stop-transcript

I don't know any rocket scientists, which is okay because it doesn't need one to work out that you need to replace "<path>" in the script with an appropriate folder name.

Useful links (Lync & other)

Here are a few more useful links.

LYNC

Set-CsLync2013Prereqs.ps1 – Easily install prerequisites and tools for Microsoft Lync Server 2013 - http://www.ehloworld.com/1697

Lync products: http://www.techland.co.uk/ & http://www.vcomm.com/

OTHER

Mounting an ISO to a HP iLO over HTTP - http://torxsmind.blogspot.co.uk/search/label/iLO

Exchange Management Shell tips

This article has been ported from my old TechBlog as it is still valid and useful.

I’ve used loops to perform repeated tasks before but hit a snag with one that I wanted to do. It’s easy to vary an object with a number variable. For example:

1..4 | Foreach-object {Get-ExchangeServer -Identity SERVER0"$_"}

returns SERVER01, SERVER02, SERVER03, SERVER04.

Simples as Bob would say.

But trying to do that in a command that is already incorporating quotes (because there are spaces) poses a new dilemma. What am I on about? Look at the following example:

Set-OWAVirtualDirectory -Identity "SERVER0"$_"\OWA (Default Web Site)" -ExternalUrl https://mail.company.com/owa

That won’t work.

Don’t panic Mr Mainwaring, don’t panic

I have a solution and it works a treat. Break up the text and define it as a variable(s). Like this:

$dir = "\OWA (Default Web Site)"; 1..4 | Foreach-object {Set-OWAVirtualDirectory -Identity SERVER0"$_"$dir -ExternalUrl https://mail.company.com/owa}

So that one liner basically does this:

Set-OWAVirtualDirectory -Identity SERVER01\OWA (Default Web Site) -ExternalUrl https://mail.company.com/owa
Set-OWAVirtualDirectory -Identity SERVER02\OWA (Default Web Site) -ExternalUrl https://mail.company.com/owa
Set-OWAVirtualDirectory -Identity SERVER03\OWA (Default Web Site) -ExternalUrl https://mail.company.com/owa
Set-OWAVirtualDirectory -Identity SERVER04\OWA (Default Web Site) -ExternalUrl https://mail.company.com/owa




Exchange 2010 Datacenter failover and switchback scripts

This article has been ported from my old TechBlog as it is still valid and useful.

I’ve been lapping up some sunshine in the garden but the weather is now changing again, so it’s back indoors and time to post something. From some recent work I was doing, here are some scripts for DAG failover to DR site and switchback again. There are specific assumptions here; firstly, I was working with two mailbox servers in my main site and a single mailbox server in the DR site. Secondly, I had a single DAG. Thirdly, I was using the same CAS Array for both sites – that is not necessarily always going to be the case, but this was just a DR site, so was appropriate for me. Finally, I was blocking database activation in the DR site. You can easily modify the scripts according to your circumstances and need to modify some of the tags anyway.

< MAIN_SITE>
< DR_SITE>
< DAGNAME>
< DR_MBX_SERVER>
< CASARRAY>

In my example there are 15 mailbox databases named DB01-DB15.

#### TERMINATE FAILED DATACENTER
#### if mailbox server(s) in are still powered on but not functioning properly

POWER OFF

### or
Stop-DatabaseAvailabilityGroup -ActiveDirectorySite -Confirm:$false

#### if AD is available in but servers went off before doing the previous step
Stop-DatabaseAvailabilityGroup -ActiveDirectorySite -ConfigurationOnly -Confirm:$False

#### check that the mailbox servers have stopped in
Get-DatabaseAvailabilityGroup | select Name,*server*

#### run in
Stop-DatabaseavailabilityGroup -ActiveDirectorySite -ConfigurationOnly -Confirm:$False

#### ACTIVATE DR SITE
#### run in

stop-service ClusSvc
Restore-DatabaseAvailabilityGroup -ActiveDirectorySite -Confirm:$False

(repeat above if necessary)

1..9 | ForEach-Object {Move-ActiveMailboxDatabase DB0"$_" -ActivateOnServer -SkipActiveCopyChecks -MountDialOverride:None –confirm:$false}; 0..5 | ForEach-Object {Move-ActiveMailboxDatabase DB1"$_" -ActivateOnServer -SkipActiveCopyChecks -MountDialOverride:None –confirm:$false}
Set-clientaccessarray –site –confirm:$false


#### SWITCHBACK
#### run in after site is brought back up

Start-DatabaseAvailabilityGroup -ActiveDirectorySite
(repeat above if necessary)

Set-clientaccessarray –site –confirm:$false

#### check that mailbox servers in show as started in DAG ()

Get-DatabaseAvailabilityGroup | select Name,*server*

#### move databases back to

origlocation$=get-location; set-location exscripts$; .\RedistributeActiveDatabases.ps1 - -BalanceDbsByActivationPreference -ShowFinalDatabaseDistribution -Confirm:$false; set-location origlocation$

(repeat above if necessary)
#### if appropriate, block from activating databases when is available

Set-MailboxServer -DatabaseCopyAutoActivation:blocked

Monitor-MoveRequests.ps1

This article has been ported from my old TechBlog as it is still valid and useful.

I had to painfully watch someone move a mailbox and monitor its progress using Exchange Management Console the other day and I made a note to myself to share my mailbox move bits and pieces, especially a script ”what I writ’ to monitor move requests. I meant to add something to happen when the mailbox move is complete, but haven’t got round to it and can’t be bothered at the present time. Another day.

Here’s the Monitor-MoveRequests.ps1 script:

$moverequests = get-MoveRequest ; get-exchangeserver | ?{$_.IsE14OrLater -eq 'True'}
$A = (get-host).UI.RawUI
$A.WindowTitle = "Monitor Mailbox Move requests"
$B = $A.windowsize
$B.width = 150
$B.height = 65
$A.WindowSize = $B
while ($true) {cls; foreach ($moverequest in $moverequests) {Get-MoveRequestStatistics $moverequest | select Alias, DisplayName, StartTimestamp, TotalQueuedDuration, PercentComplete, BytesTransferred, StatusDetail, SourceDatabase, TargetDatabase,Status, TotalinProgressDuration, OverallDuration}
;sleep 5}


It may look familiar; I modified another script to make it

Here’s the rest of the stuff:

Test mailbox is ready to move:

New-MoveRequest -Identity user01@company.com -TargetDatabase "MDB01" –whatif

Move a mailbox:

New-MoveRequest -Identity user01@company.com -TargetDatabase "MDB01"

Clear a mailbox move request:

Get-MoveRequest | where {$_.status -eq "Completed"}

Clear all move requests:

Get-MoveRequest | where {$_.status -eq "Completed"} | Remove-moverequest -confirm:$False

New mailbox creation:

New-Mailbox -Name 'user01' -Alias 'user01' -OrganizationalUnit 'company.local/staff' -UserPrincipalName 'user01@company.com>' -SamAccountName 'user01' -FirstName 'user01' -Initials '' -LastName '' -ResetPasswordOnNextLogon $false -Database MDB01

Multiple move requests (enter in a ps1 script):

New-MoveRequest user01 -TargetDatabase "MDB01" -suspend
New-MoveRequest user02 -TargetDatabase "MDB02" -suspend


Start multiple move requests (enter in a ps1 script e.g. ResumeMailboxMoves.ps1):

Get-MoveRequest | Resume-MoveRequest

Powershell script as a batch file (e.g. for scheduling using Task Scheduler)(where ‘D:\Exchange’ is the Exchange install path):

PowerShell.exe -command ". 'D:\Exchange\bin\RemoteExchange.ps1'; cls; Connect-ExchangeServer -auto; & 'D:\Exchange\Scripts\ResumeMailboxMoves.ps1'"

Powershell - working with the registry

This article has been ported from my old TechBlog as it is still valid and useful.

I’ve been a good boy and taken the Lync leap. The really annoying thing I’ve always found about Lync is that it always starts up, especially when I don’t want it to. I reboot my laptop at home in the evening or at the weekend and the next thing I know is people are trying to contact me because they thing I’m working. Please. Working outside working hours? You don’t know me well enough.
So I set about doing something about it.

I started by tracking down what was forcing the Lync startup. I’m running Windows 7 64-bit and I found it here:

HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Run
"Communicator"=”C:\Program Files (x86)\Microsoft Lync\communicator.exe" /fromrunkey


So I set about nobbling that and replacing it with a Scheduled task that runs every weekday at 9am that starts up Lync.

Guess what? It works.

But this post would be far too simple and boring if that’s all I included in it. So let’s use some Powershell and to make this whole process a lot more complicated. But seriously, this is a great opportunity to demonstrate how to work with the Registry using Powershell and to introduce a script I found to help.

The script I found creates a .reg backup of Registry keys / values. The beauty of this is that you can then easily script and record what you are doing. I found the script here: http://franckrichard.blogspot.co.uk/2010/12/generate-reg-regedit-export-to-file.html

It’s quite clearly not my script, but I’ve used it and it does what it says on the tin. I found that I needed to specify ‘HKEY_LOCAL_MACHINE’ instead of ‘HKLM’, but with that heads-up you should find it easy to use. The script is included at the bottom of this page and can also be downloaded directly here. Don’t forget about your execution policy, although Powershell will prompt you if you have forgotten.