SCSM and PowerShell


Hi,

I am trying to change a Runbook activity status to "Failed" in SCSM using the below command in SCSM:

Set-SCSMObject -SMObject $Object -Property Status -Value "Failed"

But I get the below error when I run it:


Set-SCSMObject : Unable to cast object of type 'System.String' to type 'Microsoft.EnterpriseManagement.Common.EnterpriseManagementObject'.

Does anyone know how to fix it or what is wrong with that code block?

Any help will be appreciated.

Thanks

September 4th, 2015 5:56am

Perhaps you should ask your question in SCSM forum.

From your example we have no idea what is $Object.

You can try:

$Object | Get-Member

and check if property 'Status' might be read only? 

Free Windows Admin Tool Kit Click here and download it now
September 4th, 2015 8:38am

I am manually assigning a Runbook ID for testing purposes to $Object. e.g. $Object = RB12345. Then I am trying to see if Set-SCSMObject changes the status of that activity to failed.

I agree that this should better be posted on SCSM forum and just done that.

Thanks :)

September 6th, 2015 9:15pm

You cannot use a string for an object.  Either use the object or change the code.

Free Windows Admin Tool Kit Click here and download it now
September 6th, 2015 9:39pm

Yes, jrv point is correct - Recently our DPM team asked me the fix for similar issue -

Get-DPMDatasource -ProductionServer DPMServer

Error:

Get-DPMDatasource : Cannot bind parameter 'ProductionServer'. Cannot convert the "DPMServer
" value of type "System.String" to type "Microsoft.Internal.EnterpriseStorage.Dls.UI.Objec
tModel.OMCommon.ProductionServer".

What we did is like below - This is just for demo

$ps = Get-DPMProductionServer
Get-DPMDatasource -ProductionServer $ps[0]

September 7th, 2015 3:11am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics