2

Im currently in the process of automating an install process for a custom windows application and trying to remove a couple of the com+ applications including everything below it.

Obviously this can be done manually with a right click and delete but I need something to streamline this process and I can add powershell to my automation process.

I have tried the below code but it only seems to remove the components with in the application. While this helps I would then need to remove the application in another step.

$comCatalog = New-Object -ComObject COMAdmin.COMAdminCatalog
$appColl = $comCatalog.GetCollection("Applications")
$appColl.Populate()

$app = $appColl | where {$_.Name -eq "ApplicationName"}
$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++
}

I would expected to be able to remove the application and have everything below also removed.

1 Answer 1

1
$comCatalog = New-Object -ComObject COMAdmin.COMAdminCatalog
$appColl = $comCatalog.GetCollection("Applications")
$appColl.Populate()

for ($i=0; $i -lt $appColl.Count; $i++)
{
if ($appColl.Item($i).Name -eq "YourComponentName"){ $appColl.Remove($i) $appColl.SaveChanges() }}
Sign up to request clarification or add additional context in comments.

Comments

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.