Skip to content

Import-Metadata

SYNOPSIS

Creates a data object from the items in a Metadata file (e.g. a .psd1)

SYNTAX

Import-Metadata [-Path] <String> [[-Converters] <Hashtable>] [-Ordered] [[-AllowedVariables] <String[]>]
 [[-PSVariable] <PSVariableIntrinsics>] [<CommonParameters>]

DESCRIPTION

Serves as a wrapper for ConvertFrom-Metadata to explicitly support importing from files

EXAMPLES

EXAMPLE 1

$data = Import-Metadata .\Configuration.psd1 -Ordered

Convert a module manifest into a hashtable of properties for introspection, preserving the order in the file

PARAMETERS

-Path

The path to the metadata (.psd1) file to import

Type: System.String
Parameter Sets: (All)
Aliases: PSPath, Content

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

-Converters

A hashtable of MetadataConverters (same as with Add-MetadataConverter)

Type: System.Collections.Hashtable
Parameter Sets: (All)
Aliases:

Required: False
Position: 2
Default value: @{}
Accept pipeline input: False
Accept wildcard characters: False

-Ordered

If set (and PowerShell version 4 or later) preserve the file order of configuration This results in the output being an OrderedDictionary instead of Hashtable

Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases:

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

-AllowedVariables

Allows extending the valid variables which are allowed to be referenced in metadata BEWARE: This exposes the value of these variables in the calling context to the metadata file You are reponsible to only allow variables which you know are safe to share

Type: System.String[]
Parameter Sets: (All)
Aliases:

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

-PSVariable

You should not pass this. The PSVariable parameter is for preserving variable scope within the Metadata commands

Type: System.Management.Automation.PSVariableIntrinsics
Parameter Sets: (All)
Aliases:

Required: False
Position: 4
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

OUTPUTS

NOTES

Back to top