I am wanting to automate my server installations.
Part of this includes Creating COM+ packages (which I do currently with PS). I then need to add components to these empty application packages. The DLLs have been pre-registered with RegASM.
At the moment I am adding the components in manually through DCOM config GUI (add components that are already registered \ 32bit components). I then set the transaction support level on each component through properties after they have been added in. On an application with 50+ components this can get very time consuming, hence the need for automation.
I have found a script to remove specific components...
$comCatalog = New-Object -ComObject COMAdmin.COMAdminCatalog
$appColl = $comCatalog.GetCollection("Applications")
$appColl.Populate()
$app = $appColl | where {$_.Name -eq "COMAPPNAME"}
$compColl = $appColl.GetCollection("Components", $app.Key)
$compColl.Populate()
$index = 0
foreach($component in $compColl) {
if ($component.Name -eq "SOMECOMPONENT.NAME") {
$compColl.Remove($index)
$compColl.SaveChanges()
}
$index++
}
... Modifying the above, this is what I have so far however it errors with the Bitness and Transaction options present. Without these it runs without error. But, nothing seems to happen. No components appear in my COM+ application.
$comAdmin = New-Object -comobject COMAdmin.COMAdminCatalog
$apps = $comAdmin.GetCollection("Applications")
$apps.Populate();
$app = $apps | where {$_.Name -eq "App1"}
$compColl = $apps.GetCollection("Components", $app.Key)
$compColl.Populate()
$component = $compColl.Add
$component.Value("Bitness") = 0x1
$component.Value("Transaction") = 2
$component.Name -eq "App1.Component1"
$compColl.SaveChanges()
$comAdmin = New-Object -comobject COMAdmin.COMAdminCatalog
$apps = $comAdmin.GetCollection("Applications")
$apps.Populate();
$app = $apps | where {$_.Name -eq "App1"}
$compColl = $apps.GetCollection("Components", $app.Key)
$compColl.Populate()
$component = $compColl.Add
$component.Value("Bitness") = 0x1
$component.Value("Transaction") = 3
$component.Name -eq "App1.Component2"
$compColl.SaveChanges()
Any help would be greatly appreciated!
Thanks!