This study examines the dynamic control of an M/M/2 machine repair system with R operating machines, S standbys, and two unreliable repairmen, wherein standbys are subject to switching failures. We apply the matrix analytic method to derive explicit expressions of the stationary probability distributions as well as matrix expressions of the system performance measures. We construct a cost model and determine the optimal dynamic operating policy to minimize the expected cost function per unit time. Sensitivity analysis is conducted using numerical examples. The results of sensitivity analysis indicate that the optimal thresholds and corresponding minimum expected cost increase as the number of operating machines or standbys increases. Moreover, the minimum expected cost is sensitive to the mean arrival and repair rates. The results provide managers with decision reference for productivity improvement and cost reduction.