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");

= New-Object -ComObject WScript.Shell;
    Start-Sleep -Seconds 2; 

    foreach ($myComputer in $computer) {
        @('^m', '%d', 'cc', '~c~a{right}', "$myComputer~") | % {
            Start-Sleep -Seconds 1;


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.

Comments (0)

Skip to main content