简体   繁体   中英

Remove Com+ Application using powershell

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.

$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() }}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM