Skip to content

ConvertTo Dictionary

Apostolis Bekiaris edited this page Apr 26, 2020 · 4 revisions

external help file: XpandPwsh-help.xml Module Name: XpandPwsh online version: schema: 2.0.0

ConvertTo-Dictionary

SYNOPSIS

Converts a pipeline to a dictionary.

SYNTAX

ConvertTo-Dictionary [-Object] <Object> [-KeyPropertyName] <String> [-ValuePropertyName <String>]
 [-ValueSelector <ScriptBlock>] [-Force] [-Ordered] [<CommonParameters>]

DESCRIPTION

Converts a pipeline to a dictionary.

EXAMPLES

Example 1

PS C:\> [hashtable]$dxNugetPackagesPath = $dxPath | ForEach-Object { 
            [PSCustomObject]@{
                Name = $_.Name
                Path="$($_.Directory)\System\Components\packages" 
            }
        }|ConvertTo-Dictionary -KeyPropertyName name -ValueSelector {$_.Path}

Convert a collection of paths into a dictionary with key the directory name and value the path.

PARAMETERS

-Force

{{ Fill Force Description }}

Type: SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-KeyPropertyName

{{ Fill KeyPropertyName Description }}

Type: String
Parameter Sets: (All)
Aliases:

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

-Object

{{ Fill Object Description }}

Type: Object
Parameter Sets: (All)
Aliases:

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

-Ordered

{{ Fill Ordered Description }}

Type: SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-ValuePropertyName

{{ Fill ValuePropertyName Description }}

Type: String
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-ValueSelector

{{ Fill ValueSelector Description }}

Type: ScriptBlock
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
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

System.Object

OUTPUTS

System.Object

NOTES

RELATED LINKS

image

image


Star the project if you think it deserves it.

GitHub stars

Fork the project to extend and contribute.

GitHub forks

Clone this wiki locally