Customer asks how to get the owner of a service using SMLets on this forum thread:
No problem! This is really just a variation on the following blog post:
In this example first we need to get the service using Get-SCSMObject and Get-SCSMClass. The class in this case is System.Service (that will get all services created in SCSM and imported from SCOM. In this case I chose to get the object using the display name. You could get it in other ways using other properties too.
Then we need to get the related object using the Get-SCSMRelatedObject cmdlet. We pass the service as the source object and specify the GUID for the System.ConfigItemOwnedByUser relationship type.
The whole solution looks like this:
Just want to ask on how to get the Id of a service using c# code. I used the system.service class and I want to get the Id of a service that is imported from operations manager.
Thanks in advance.
I have used this very useful peace of powershell script but found an error while using it. If you have changed Service Owner on a Business Service, you get several targetobjects and it cannot decide which to choose. It should be able to be solved using the IsDeleted property set to true (even though when i use it I have to set it IsDeleted -ne false to get the correct owner, very strange)