2

I am attempting to automate my server installations as much as possible.

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!

0

1 Answer 1

2

I have found a suitable solution:

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

This does exactly what I need.

Sign up to request clarification or add additional context in comments.

2 Comments

Cannot find an overload for "InstallComponent" and the argument count: "2" is the error I get. any ideas?
Ok, I had to add two more arguments after the [DLL containing components], "", "")

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.