Learn to use the PowerShell cmdlet for testing the Microsoft Distributed Transaction Coordinator (MSDTC)

The following article assume the following:

        1. You have no firewall between the server and client or it has been disabled or configured to allow for DTC traffic to occur.

        2. The authentication scheme for DTC is supported by both server and client.

        3. The tester is running as system administrator with elevated permissions.

        4. You have permissions to execute PowerShell commands. (set-executionPolicy)

 

* You may use the MMC for Component Services to view the Transaction Statistics during this exercise. Load Component Services from the Administrative Tools and navigate to:

        [MMC\Component Services\Computers\My Computer\ Distributed Transaction Coordinator\Local DTC\Transaction Statistics]

How to perform a local transaction

                1. Open C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe as Administrator

                2. Run the following command:

Start-DtcDiagnosticResourceManager

                3. Now create a variable to hold a DtcDiagnosticTransaction by running the following command:

                $transObject = New-DtcDiagnosticTransaction

                4. To send the transaction, run the following command:

                Send-DtcDiagnosticTransaction –Transaction $transObject

                (Notice the Transaction Statistics now show an active transaction)                

                5. Now complete the transaction by issuing this command:

Complete-DtcDiagnosticTransaction $transObject

                (Notice the transaction should be committed)                

                6. If you are finished testing, you can stop the Resource Manager by issuing this command:

Stop-DtcDiagnosticResourceManager -Name "DtcDiagRM:3002"

              

How to perform a distributed transaction

For our example, I’ve named the two machines Server1x64 and Client1x64 to act as participants in a Distributed Transaction.   

        Perform these steps on the Server1x64

1. Open C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe as Administrator               
2. Run the following command:

Start-DtcDiagnosticResourceManager   

        Perform these steps on the Client1x64

1. Create a variable to hold a DtcDiagnosticTransaction by running the following command:

$transObject = New-DtcDiagnosticTransaction

               
2. To send the transaction, run the following command:

Send-DtcDiagnosticTransaction –ComputerName Server1x64 –Transaction $transObject

               
3. Now complete the transaction by issuing this command:

Complete-DtcDiagnosticTransaction $transObject

                      

Cleanup: Perform these steps on the Server1x64

If you are finished testing, you can stop the Resource Manager by issuing this command:

Stop-DtcDiagnosticResourceManager -Name "DtcDiagRM:3002"

References:

 

Using the Set-ExecutionPolicy Cmdlet

https://technet.microsoft.com/en-us/library/ee176961.aspx

 

Configuring Microsoft Distributed Transaction Coordinator (DTC) to work through a firewall

https://support.microsoft.com/kb/250367

 

Microsoft.Dtc.PowerShell.Diagnostics

https://msdn.microsoft.com/en-us/library/windows/desktop/hh438328(v=VS.85).aspx