Thursday, November 14, 2013

Starting Exchange in Lync 2013 Test Drive VM set

In a recent blog article here, I wrote about the cool VM set that Microsoft has published that lets you play with a working implementation  of Lync Server. In that article, I wrote: “As in most classroom scenarios, starting the VMs all at once means a lot of services do not start cleanly – but it’s nothing that a bit of PowerShell can’t quickly remedy”.  Having played a bit with this, I can say that in all but a controlled startup, services and dependent services for both Lync and Exchange do not always come up cleanly.

I was playing today and saw this on the 2013-Exchange Server:

[hyperv] PS C:> $conf = {
>> $Donotrestart = @
>> ('RemoteRegistry', 'MSDTC', 'NetTcpActivator', 'HostControllerService')
>> # get all the unstarted RTC services and start them.
>> Get-WMIObject -Class win32_service   |
>>     Where {$_.startmode -EQ 'Auto'}    |
>>        Where {$_.State -NE 'Running'}  |
>>          Where {$Donotrestart -notcontains $_.name} }

[hyperv] PS C:> Invoke-Command –Computer 2013-Exchange –ScriptBlock `
        
$conf -Credential $CredC | Format-Table

ExitCode  Name    ProcessId StartMode State    Status  PSComputerName
--------  ----    --------- --------- -----    ------  --------------         
0         FMS             0 Auto      Stopped  OK      2013-Exchange          
0         HostControll…   0 Auto      Stopped  OK      2013-Exchange          
0         MSDTC           0 Auto      Stopped  OK      2013-Exchange
1068      MSExchangeA…    0 Auto      Stopped  OK      2013-Exchange
1068      MSExchangeAnt…  0 Auto      Stopped  OK      2013-Exchange          
1068      MSExchangeDel…  0 Auto      Stopped  OK      2013-Exchange
0         MSExchangeDiag… 0 Auto      Stopped  OK      2013-Exchange          
1068      MSExchangeEdg…  0 Auto      Stopped  OK      2013-Exchange           
1068      MSExchangeFas…  0 Auto      Stopped  OK      2013-Exchange
1068      MSExchangeFro…  0 Auto      Stopped  OK      2013-Exchange          
0         MSExchangeHM    0 Auto      Stopped  OK      2013-Exchange          
1068      MSExchangeIS    0 Auto      Stopped  OK      2013-Exchange
1068      MSExchangeMa…   0 Auto      Stopped  OK      2013-Exchange          
1068      MSExchangeMai…  0 Auto      Stopped  OK      2013-Exchange          
1068      MSExchangeRepl  0 Auto      Stopped  OK      2013-Exchange          
1068      MSExchangeRPC   0 Auto      Stopped  OK      2013-Exchange          
1068      MSExchangeServ… 0 Auto      Stopped  OK      2013-Exchange          
1068      MSExchangeSubm… 0 Auto      Stopped  OK      2013-Exchange          
1068      MSExchangeThr…  0 Auto      Stopped  OK      2013-Exchange          
1068      MSExchangeTran… 0 Auto      Stopped  OK      2013-Exchange          
1068      MSExchangeTran… 0 Auto      Stopped  OK      2013-Exchange          
1068      MSExchangeUM    0 Auto     
Stopped  OK      2013-Exchange          
1068      MSExchangeUMCR  0 Auto      Stopped  OK      2013-Exchange          
0         NetMsmqActiva…  0 Auto      Stopped  OK      2013-Exchange          
1068      NetTcpActivator 0 Auto      Stopped  OK      2013-Exchange          
0         NetTcpPortSha…  0 Auto      Stopped  OK      2013-Exchange          

With this sort of startup, of course Exchange is not going to work well, and those part of Lync that rely on Exchange will fail too. I’ve been seeing situations similar to this for a very long time. The solution is, as I mentioned in the earlier article pretty simple – use a PowerShell script to deal with this.

In my case I have a script that starts up all the VMs from scratch, as described in a recent blog post here: http://tfl09.blogspot.dk/2013/10/starting-up-lync-test-drive-vm-farm.html/. In most cases, that script starts things up slowly enough that this sort of massive service start failure does not occur. Well, does not usually occur.

I how have an updated pair of scripts that I run from my Hyper-V host that detects any of the relevant services that failed (and that are relevant), and does a manual start. Here’s the script I use to detect and correct non-starting Exchange components:

#  Start services for Exchange In Lync Test Drive Lab
#  Runs on Hyper-V Host

# Set credentials
$Username   = "Contoso\administrator"
$Password   = 'pass@word1'
$PasswordSS = ConvertTo-SecureString  -String $Password -AsPlainText -Force
$CredC      = New-Object -Typename System.Management.Automation.PSCredential `
                -Argumentlist $Username,$PasswordSS

$conf = {
$Donotrestart = @('RemoteRegistry', 'MSDTC', 'NetTcpActivator', 'HostControllerService')
# get all the unstarted RTC services and start them.
Get-WMIObject -Class win32_service   |
    Where {$_.startmode -EQ 'Auto'}    |
       Where {$_.State -NE 'Running'}  |
         Where {$Donotrestart -notcontains $_.name}}

# Now run this on the Exchange VM
Invoke-Command -ComputerName 2013-Exchange -ScriptBlock $conf -Credential $CredC | ft

With this in place, I start up the labs, wait a few more minutes, then run this script to ensure that Exchange is all up and tickety-boo!

The joys of large VM sets and PowerShell!

No comments: