Skip to content

ConvertTo CimInstance

dscbot edited this page Sep 30, 2024 · 3 revisions

ConvertTo-CimInstance

SYNOPSIS

Converts a hashtable into a CimInstance array.

SYNTAX

ConvertTo-CimInstance [-Hashtable] <Hashtable> [[-ClassName] <String>] [[-Namespace] <String>]
 [<CommonParameters>]

DESCRIPTION

This function is used to convert a hashtable into MSFT_KeyValuePair objects. These are stored as an CimInstance array. DSC cannot handle hashtables but CimInstances arrays storing MSFT_KeyValuePair.

EXAMPLES

EXAMPLE 1

ConvertTo-CimInstance -Hashtable @{
    String = 'a string'
    Bool   = $true
    Int    = 99
    Array  = 'a, b, c'
}

This example returns an CimInstance with the provided hashtable values.

PARAMETERS

-ClassName

The ClassName of the CimInstance to create.

Default value is to 'MSFT_KeyValuePair'.

Type: String
Parameter Sets: (All)
Aliases:

Required: False
Position: 2
Default value: MSFT_KeyValuePair
Accept pipeline input: False
Accept wildcard characters: False

-Hashtable

A hashtable with the values to convert.

Type: Hashtable
Parameter Sets: (All)
Aliases:

Required: True
Position: 1
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: False

-Namespace

The Namespace of the CimInstance to create.

Default value is to 'root/microsoft/Windows/DesiredStateConfiguration'.

Type: String
Parameter Sets: (All)
Aliases:

Required: False
Position: 3
Default value: Root/microsoft/Windows/DesiredStateConfiguration
Accept pipeline input: False
Accept wildcard characters: False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

INPUTS

OUTPUTS

System.Object[]

NOTES

RELATED LINKS

Clone this wiki locally