Powershell and COM objects

The code below stops service.

$comAdmin = New-Object -com ("COMAdmin.COMAdminCatalog.1")
$comAdmin.ShutdownApplication("US Business Objects")

Open in new window

What would the code be to check status of COM object before and after I stop service?
Leo TorresSQL DeveloperAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Qlemo"Batchelor", Developer and EE Topic AdvisorCommented:
The specific COM object implements status members. Aside from "does the object exist" (the result not being $null or an empty object), there is nothing generic you can check.
Leo TorresSQL DeveloperAuthor Commented:
OK so there is no way to check is COM object is running or not?
Qlemo"Batchelor", Developer and EE Topic AdvisorCommented:
No. If you get an object, the process hosting the object is running - necessarily. If the object can check for the status of other processes, it is different, and that might be what you are after. I'll check the COM object you use to see if I can find out more.
Making Bulk Changes to Active Directory

Watch this video to see how easy it is to make mass changes to Active Directory from an external text file without using complicated scripts.

Leo TorresSQL DeveloperAuthor Commented:
Mind you the "US Business Objects" i am using is an internal object your going to have to use another Object.
Qlemo"Batchelor", Developer and EE Topic AdvisorCommented:
In a quick glance, going thru all COM app instances, and checking for the GUID matching, is the only way to check if all instances are shut down (see http://www.31a2ba2a-b718-11dc-8314-0800200c9a66.com/2008/11/shutting-down-running-com-instance_9879.html for non-PS example code).
Qlemo"Batchelor", Developer and EE Topic AdvisorCommented:
Can't test, as I don't have any COM object available in the factory, so I'll have to provide something for you to test:
$comAdmin = New-Object -com ("COMAdmin.COMAdminCatalog.1")
# $comAdmin.ShutdownApplication("US Business Objects")

$instances = $comAdmin.GetCollection("ApplicationInstances")

foreach ($instance in $instances)
  $instance.Name | Write-Host

Open in new window

I expect you to see "US Business Objects", if the COM service is running. $instance is a COMAdmin.COMAdminCatalogObject, described here https://msdn.microsoft.com/en-us/library/windows/desktop/ms679228(v=vs.85).aspx, but that doesn't help much ;-).

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Leo TorresSQL DeveloperAuthor Commented:
Thank you, out of office till Friday morning will try to get to it before then thank you!
Leo TorresSQL DeveloperAuthor Commented:
Havent had Chance to test but I have confidence  in your code. will update at some point for now I will give you credit.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.