Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 8583

Passing CIMInstance as arguments to methods using 'Invoke-CimMethod'

$
0
0

I want to invoke CIM class method and pass CIM instance as argument to the method. The below scripts executes properly but the argument is not reaching the provider. I have put the traces in provider it reports NULL as argument. 

How do I debug this issue? or is there any way to pass the CIM Class instances as arguments?

Note: If method arguments are general type (int, string) then it works properly.

Eg:

$objfcPort= Get-CimInstance -Class CIM_FCPort -NameSpace root\xx -KeyOnly

$firstObject = $objfcPort[0]

Write-Host "The first object is " $firstObject

$objDumpService = Get-CimInstance -Class CIM_DumpService -NameSpace root\XX

Write-Host "The Dump Service object" $objDumpService

Invoke-CimMethod -InputObject $objDumpService -MethodName Dump -Arguments @{Target= [ciminstance[]]@($firstObject)}

Invoke-CimMethod -InputObject $objDumpService -MethodName Dump -Arguments @{Target= $firstObject}


Viewing all articles
Browse latest Browse all 8583

Trending Articles