Import-PowerShellDataFile
Imports values from a .PSD1 file without invoking its contents
Syntax
ByPath (Default)
Import-PowerShellDataFile
[[-Path] <String[]>]
[<CommonParameters>]
ByLiteralPath
Import-PowerShellDataFile
[-LiteralPath <String[]>]
[<CommonParameters>]
Description
The Import-PowerShellDataFile cmdlet returns a hashtable consisting of the key-value pairs in a
.PSD1 file.
Examples
Example 1: Retrieve values from PSD1
$content = Import-PowerShellDataFile .\Configuration.psd1
$content
Name Value
---- -----
key1 value1
key2 value2
This examples retrieves the key-value pairs stored in the hashtable kept inside the Configuration.psd1 file.
Parameters
-LiteralPath
The path to the file being imported. All characters in the path are treated as literal values. Wildcard characters are not processed.
Parameter properties
| Type: | String[] |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
| Aliases: | PSPath |
Parameter sets
ByLiteralPath
| Position: | Named |
| Mandatory: | False |
| Value from pipeline: | False |
| Value from pipeline by property name: | True |
| Value from remaining arguments: | False |
-Path
The path to the file being imported. Wildcards are allowed but only the first matching file is imported.
Parameter properties
| Type: | String[] |
| Default value: | None |
| Supports wildcards: | True |
| DontShow: | False |
Parameter sets
ByPath
| Position: | 0 |
| Mandatory: | False |
| Value from pipeline: | False |
| Value from pipeline by property name: | False |
| Value from remaining arguments: | False |
CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.