Tuesday, April 28, 2009

KiXtart Script: Building an MMC Console

This is based on a VBScript example posted a while back by the renown, the incredible, Mr. Don Hite. I mixed in some code from the MSDN MMC Automation object model reference documentation, poured it all into a KiXtart blender and punched the puree button. Be mindful of word-wrapping on the longer strings.

; Filename..: mmc.kix
; Author....: David M. Stein
; Date......: 04/28/2009
; Purpose...: build and save a custom MMC console
Break ON

$consoleName = "C:\MyConsole.msc"

If Exist($consoleName)
? "info: console already created as $consoleName"
? "info: console not found, building now..."
$objMMC = CreateObject("MMC20.Application")
$objDoc = $objMMC.Document
$objSnapIns = $objDoc.SnapIns
$objFolder = $objSnapIns.Add("Folder")
$nul = $objMMC.Document.SnapIns.Add("Active Directory Users and
$nul = $objMMC.Document.SnapIns.Add("Active Directory Sites and
$nul = $objMMC.Document.SnapIns.Add("Active Directory Domains
and Trusts")
$objMMC.UserControl = 1
$objMMC.Document.Name = $consoleName
? "info: console built and saved as $consoleName"
Post a Comment