Creating a Multi-Host Cert MMC

MMCs are a mixed blessing at best.  The saved .msc files aren't human-editable (read: not XML) so I don't have an easy way to create them.  In this case, I need to perform a cert audit on all the machine certs in a lab.  PowerShell eschews 'parsing by prayer', but this is pretty much what I have to do:

function New-CertMMC {
    param ( [String[]]$computer) ;   

    [void] [System.Reflection.Assembly]::LoadWithPartialName("'Microsoft.VisualBasic");
    [void] [System.Reflection.Assembly]::LoadWithPartialName("'System.Windows.Forms");

$wshell = New-Object -ComObject WScript.Shell;
    $wshell.Run("mmc.exe");
    Start-Sleep -Seconds 2;

[Microsoft.VisualBasic.Interaction]::AppActivate("Console1");
    foreach ($myComputer in $computer) {
    @('^m', '%d', 'cc', '~c~a{right}', "$myComputer~") | % {
    [System.Windows.Forms.SendKeys]::SendWait("$_");
    Start-Sleep -Seconds 1;
        }
    [System.Windows.Forms.SendKeys]::SendWait('{esc}~');
    }
}

 

One HUGE caveat - SendKeys is horribly 'brittle'.  In this case, these keystrokes are ONLY for Server 2003 and below.  They won't work for 2K8, Vista, etc.  Additionally, Vista and above's UAC prompt seems to cause problems as well.