VMware Cloud Community
vromanowski
Enthusiast
Enthusiast
Jump to solution

Powershell CIM cmdlets with a custom namespace/provider

We have a CIM provider with our own namespace, etc. I'm trying to figure out how to enumerate instance of our classes, call methods, etc... but as soon as I change the namespace I get an "Invalid Argument".

Using a WBEM client everything works fine however. It seems that our issues are only when trying to use WS-MAN.

import-module CimCmdlets

$Ipaddress = "10.102.206.99"

$HostUsername = Get-Credential root

$CIOpt = New-CimSessionOption -SkipCACheck -SkipCNCheck -SkipRevocationCheck -Encoding Utf8 -UseSsl

$Session = New-CimSession -Authentication Basic -Credential $HostUsername -ComputerName $Ipaddress -port 443 -SessionOption $CIOpt

$Session

Get-CimInstance -CimSession $Session -Namespace "root/cimv2" -ClassName "CIM_ComputerSystem" <==== works fine, returns info

Get-CimInstance -CimSession $Session -Namespace "root/cimv2" -ClassName "CIM_Processor" <==== works fine

Get-CimInstance -CimSession $Session -Namespace "root/cimv2" -ClassName "CIM_EthernetPort" <==== works fine

Get-CimInstance -CimSession $Session -Namespace "micron/cimv2" -ClassName "MICRON_SATADevice"    <==== This one blows up

Get-CimInstance : The WS-Management service cannot process the request. The resource URI is missing or it has an

incorrect format. Check the documentation or use the following command for information on how to construct a resource

URI: "winrm help uris".

At C:\Users\kvroman\Desktop\kvroman.ps1:14 char:1

+ Get-CimInstance -CimSession $Session -Namespace "micron/cimv2" -ClassName "MICRO ...

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : InvalidArgument: (micron/cimv2:MICRON_SATADevice:String) [Get-CimInstance], CimException

    + FullyQualifiedErrorId : HRESULT 0x8033803b,Microsoft.Management.Infrastructure.CimCmdlets.GetCimInstanceCommand

    + PSComputerName        : 10.102.206.99

Anyone have any ideas?

0 Kudos
21 Replies
vromanowski
Enthusiast
Enthusiast
Jump to solution

I believe the provider is properly registered. I turned CIMOM logging on like you suggested, and I see our provider getting registered.

Plus, it can be used via WBEM.

I don't think using WBEM is unplanned by VMware, most of the examples out there use WBEM, and even the VMware docs mention using WBEM.

I believe if anything, WS-MAN is the one less used/supported when communicating with the SFCB CIMOM - since SFCB only supports Cim-XML over HTTP and openwsman is just proxying the request to SFCB.

I think you're right in that I need a resource URI. I just don't know what that would be. Either that, OR VMware or openwsman aren't configured to handle other/custom CIM namespaces

0 Kudos
vromanowski
Enthusiast
Enthusiast
Jump to solution

I was able to get it working...

I had to edit /etc/openwsman/openwsman.conf.templ

I had to add an entry to 'provider_namespaces'. We never defined a resource URI so I just made one up, and then in powershell I just appended the class name I wanted

provider_namespace = ~~whatever is already there~~, MICRON=http://schemas.micron.com/wbem/wscim/1/cim-schema/2

and then:

Get-CimInstance -CimSession $Session -Namespace "micron/cimv2" -ResourceUri "http://schemas.micron.com/wbem/wscim/1/cim-schema/2/MICRON_Device"

0 Kudos