Now that Windows Server 2008 R2 is RTM and the book is done, I can get to some of the things that were impossible to do prior to getting Pro SQL Server 2008 Failover Clustering out the door.

One of the things I was not able to do was document how to create the Microsoft Distributed Transaction Coordinator using PowerShell. It is not hard, but it also isn’t the most straightforward task, either. Use the script below to create DTC; all you need to do is change the parameters (self-explanatory) to the right values for your environment.

$clunm = “Windows failover cluster name”
$dtcdisknm = “Name of the disk resource to use with DTC”
$dtcdnsnm = “Name for DTC in DNS”
$dtcgrpnm = “Name of the DTC resource group”
$dtcipaddr = “IP address for DTC”
$dtcsubnet = “Subnet mask for DTC”
$dtcipresnm = “Name of the DTC IP address resource”
$dtcnetnm = “Name of the DTC network name resource”
$dtcresnm = “Name of the DTC resource name”

Add-ClusterGroup $dtcgrpnm -Cluster $clunm
Add-ClusterResource $dtcipresnm -ResourceType “IP Address” -Cluster $clunm -Group $dtcgrpnm
$ipres = Get-ClusterResource $dtcipresnm
$ipaddr = New-Object Microsoft.FailoverClusters.PowerShell.ClusterParameter $ipres,Address,$dtcipaddr
$subnet = New-Object Microsoft.FailoverClusters.PowerShell.ClusterParameter $ipres,Address,$dtcsubnet
$setparams = $ipaddr,$subnet
$setparams | Set-ClusterParameter
Add-ClusterResource $dtcnetnm -ResourceType “Network name” -Cluster $clunm -Group $dtcgrpnm
$nnres = Get-ClusterResource $dtcnetnm
$netnm = New-Object Microsoft.FailoverClusters.PowerShell.ClusterParameter $nnres,Address,$dtcdnsnm
$netnm | Set-ClusterParameter
Add-ClusterResourceDependency $dtcnetnm $dtcipresnm -Cluster $clunm
Add-ClusterResource $dtcresnm -ResourceType “Distributed Transaction Coordinator” -Cluster $clunm -Group $dtcgrpnm
Add-ClusterResourceDependency $dtcresnm $dtcnetnm -Cluster $clunm
Move-ClusterResource $dtcdisknm -Cluster $clunm -Group $dtcgrpnm
Add-ClusterResourceDependency $dtcresnm $dtcdisknm -Cluster $clunm

In my next blog post, I will show you how to map MSDTC to a specific instance of SQL Server since even the current SQL Server 2008 failover clustering whitepaper gets it slightly wrong. Screenshots will be included.