1

I've scripted the start and stop of COM+ applications on a remote server using PowerShell:

function Set-ComPlusStatus {
    $comPlusApps=Get-Content $comPlusAppList
    $comObj=New-Object -comobject COMAdmin.COMAdminCatalog
    $comObj.Connect($server)
    ForEach($comPlusApp in $comPlusApps) {
        if($setStatus="stop") {
            $comObj.ShutdownApplication($comPlusApp)
        }
        elseif($setStatus="start") {
            $comObj.StartApplication($comPlusApp)
        }
    }
}

This function works i.e. it stops/starts the COM+ packages listed in the reference txt document ($comPlusAppList) as expected.

However, I would like to add some form of verification/validation to confirm that the function has been successful; ideally I'd like to check the status of the specific packages and write a success/fail message back to host based on the status.

How can the COM+ package status (stopped/running) be accessed to accomplish this?

2 Answers 2

2

Following script works:

Invoke-Command -ComputerName $compname -ScriptBlock{ $Catalog = New-   Object -com COMAdmin.COMAdminCatalog 
$oapplications = $catalog.getcollection("Applications") 
$oapplications.populate()
foreach ($oapplication in $oapplications){ 
$skeyappli = $oapplication.key 
$oappliInstances = $oapplications.getcollection("ApplicationInstances",$skeyappli) 
$oappliInstances.populate() 
# To verify if application is started 
If ($oappliInstances.count -eq 0) { 
    Write-Host "Application"$oapplication.value("Name")"is stopped" -ForegroundColor Red 
    } Else{ 
        Write-Host "Application"$oapplication.value("Name")"is Running" -ForegroundColor Green 
  }
 }
}
Sign up to request clarification or add additional context in comments.

Comments

0

I can only provide a hint of answer. I've been trying to figure this out but haven't yet. This link http://msdn.microsoft.com/en-us/library/windows/desktop/ms684369(v=vs.85).aspx should provide what you need, although I haven't figured out how to enumerate the PropertyInfo collection for the applications.

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.