# ============================================================================== # DTC Complete Configuration Script # Configures MSDTC Security, Tracing, Firewall, Service Startup, and Recovery # ============================================================================== # Ensure the script runs with Administrative privileges if (-not ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) { Write-Error "Please run this PowerShell script as an Administrator." Exit } Write-Host "Starting DTC Configuration..." -ForegroundColor Cyan # ------------------------------------------------------------------------------ # 1. Configure MSDTC Security Settings # ------------------------------------------------------------------------------ Write-Host "Configuring MSDTC Security Settings..." -ForegroundColor Yellow Set-DtcNetworkSetting -DtcName "Local" ` -InboundTransactionsEnabled $true ` -OutboundTransactionsEnabled $true ` -RemoteClientAccessEnabled $true ` -RemoteAdministrationAccessEnabled $true ` -AuthenticationLevel "NoAuth" ` -XATransactionsEnabled $true ` -LUTransactionsEnabled $true ` -Confirm:$false # ------------------------------------------------------------------------------ # 2. Configure MSDTC Tracing & Logging Options (From Screenshot) # ------------------------------------------------------------------------------ Write-Host "Configuring MSDTC Tracing and Logging Options..." -ForegroundColor Yellow $TracingPath = "HKLM:\SOFTWARE\Microsoft\MSDTC\Tracing" if (-not (Test-Path $TracingPath)) { New-Item -Path $TracingPath -Force | Out-Null } # Turn off Trace Output (TraceOutput = 0) Set-ItemProperty -Path $TracingPath -Name "TraceOutput" -Value 0 -Type DWord # Set Max. Num. Of Memory Buffers to 25 (MemoryBufferCount = 25) Set-ItemProperty -Path $TracingPath -Name "MemoryBufferCount" -Value 25 -Type DWord # ------------------------------------------------------------------------------ # 3. Configure Windows Firewall Rules # ------------------------------------------------------------------------------ Write-Host "Enabling MSDTC Firewall Rules..." -ForegroundColor Yellow # Enable Inbound Rules Enable-NetFirewallRule -DisplayGroup "Distributed Transaction Coordinator" -Direction Inbound -ErrorAction SilentlyContinue # Enable Outbound Rules Enable-NetFirewallRule -DisplayGroup "Distributed Transaction Coordinator" -Direction Outbound -ErrorAction SilentlyContinue # ------------------------------------------------------------------------------ # 4. Configure Service Startup and Recovery Options # ------------------------------------------------------------------------------ Write-Host "Configuring MSDTC Service Startup and Recovery Actions..." -ForegroundColor Yellow # Set Service Startup to Automatic Set-Service -Name "MSDTC" -StartupType Automatic # Set Service Recovery Options: Restart service on 1st, 2nd, and subsequent failures # Reset fail count after 1 day (86400 seconds), restart delay = 0 minutes sc.exe failure MSDTC reset= 86400 actions= restart/0/restart/0/restart/0 # Define DTC Tracing Registry Paths $TracingPath = "HKLM:\SOFTWARE\Microsoft\MSDTC\Tracing" $OutputPath = "HKLM:\SOFTWARE\Microsoft\MSDTC\Tracing\Output" # Create registry keys if they don't exist if (-not (Test-Path $TracingPath)) { New-Item -Path $TracingPath -Force | Out-Null } if (-not (Test-Path $OutputPath)) { New-Item -Path $OutputPath -Force | Out-Null } # 1. Uncheck "Trace Output" (0 = Disabled) Set-ItemProperty -Path $OutputPath -Name "TraceOutput" -Value 0 -Type DWord -ErrorAction SilentlyContinue Set-ItemProperty -Path $TracingPath -Name "TraceOutput" -Value 0 -Type DWord -ErrorAction SilentlyContinue # 2. Set "Max. Num. Of Memory Buffers" to 25 Set-ItemProperty -Path $TracingPath -Name "MemoryBufferCount" -Value 25 -Type DWord -ErrorAction SilentlyContinue Set-ItemProperty -Path $OutputPath -Name "MemoryBufferCount" -Value 25 -Type DWord -ErrorAction SilentlyContinue # 3. Restart MSDTC service to apply settings Restart-Service -Name "MSDTC" -Force # ------------------------------------------------------------------------------ # 5. Restart the MSDTC Service to Apply Changes # ------------------------------------------------------------------------------ Write-Host "Restarting MSDTC Service..." -ForegroundColor Yellow Restart-Service -Name "MSDTC" -Force Write-Host "`nDTC configuration completed successfully!" -ForegroundColor Green