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.