Click here to Skip to main content
15,892,517 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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!
Posted
Updated 15-Dec-14 2:01am
v2

1 solution

$comAdmin = New-Object -comobject COMAdmin.COMAdminCatalog;
$comAdmin.InstallComponent("ApplicationName", [DLL containing components]);
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900