Skip to content

Add Amended Parameter to Get-CimClass #15378

@Kriegel

Description

@Kriegel

Every time we query a CIM Instance we get Datafileds which are Numeric.
With this Numeric Values the datafields are not Human friendly and therefore needles in many cases. (eg. Asset Inventory databases)
A Human has to translate a Status Information by Hand every time.

These Numeric Values can be automatically translated into a Human friendly Text with the help of the amended (verbose) informations in a CimClass for each Property and the Qualifiers ValueMap to Values and BitMap To BitValues.

For that purpose Get-WmiObject had the -Amended Parameter.

Get-CimClass is lacking this parameter and therefore we can not get Amended Informations (on windows Systems that are not installed in en-US environment).

I followed the #PStip on PowerShellMagazin and this did not worked for me because there is simply no amended Data in a CimClass on my System with German de-DE setup. Does this works on Systems with en-US Setup?

Only if I call CimSession.GetClass() with the CimOperationOptions Flag LocalizedQualifiers
I get a CimClass with amended Data in en-US language or de-DE. Depending on my choice.

Currently I pull amended CimClasses with Get-WmiObject or with the help of a CimSession like so:

Function Get-CimClassAmended {

    [CmdletBinding()]
    param(
        [String[]]$Classname,

        [String]$NameSpace = 'root\cimv2',

        [System.Globalization.CultureInfo]$Culture = [System.Globalization.CultureInfo]'en-US'
    )

    begin {

        $AmendedDcomCIMSessionOption = New-CimSessionOption -Protocol 'Dcom' -UICulture $Culture -Culture $Culture
        $AmendedDcomCIMSessionOption.Impersonation = [Microsoft.Management.Infrastructure.Options.ImpersonationType]::Impersonate



        $AmendedDcomCimSession = New-CimSession -SessionOption $AmendedDcomCIMSessionOption



        $AmendedDcomCimOperationSessionOptions = New-Object -TypeName 'Microsoft.Management.Infrastructure.Options.CimOperationOptions'
        $AmendedDcomCimOperationSessionOptions.Flags = [Microsoft.Management.Infrastructure.Options.CimOperationFlags]::LocalizedQualifiers

    }

    process {

        ForEach ($ClassN in $Classname) {
            Try {
                # return the CIM class with amended (verbose) informations
                Write-Output $AmendedDcomCimSession.GetClass($Namespace, $ClassN, $AmendedDcomCimOperationSessionOptions)
            }
            Catch {
                Write-Error -ErrorRecord $_
            }
        }
    }
}

I only have skills with PowerShell and I am not a .NET developer.
So please Add -Amended Parameter to Get-CimClass
seems very easy.....

Metadata

Metadata

Labels

Issue-Enhancementthe issue is more of a feature request than a bugResolution-FixedThe issue is fixed.Up-for-GrabsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsWG-Cmdletsgeneral cmdlet issues

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions