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?
LVL 8
Leo TorresSQL DeveloperAsked:
Who is Participating?
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.

QlemoBatchelor, 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.
0
Leo TorresSQL DeveloperAuthor Commented:
OK so there is no way to check is COM object is running or not?
0
QlemoBatchelor, 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.
0
Creating Active Directory Users from a Text File

If your organization has a need to mass-create AD user accounts, watch this video to see how its done without the need for scripting or other unnecessary complexities.

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.
0
QlemoBatchelor, 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).
0
QlemoBatchelor, 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")
$instances.Populate()

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 ;-).
0

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!
0
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.
0
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
Powershell

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.