| external help file | Microsoft.PowerShell.Commands.Utility.dll-Help.xml |
|---|---|
| Locale | en-US |
| Module Name | Microsoft.PowerShell.Utility |
| ms.date | 04/20/2026 |
| online version | https://learn.microsoft.com/powershell/module/microsoft.powershell.utility/import-powershelldatafile?view=powershell-7.4&WT.mc_id=ps-gethelp |
| schema | 2.0.0 |
| title | Import-PowerShellDataFile |
Imports values from a .psd1 file without invoking its contents.
Import-PowerShellDataFile [-Path] <String[]> [-SkipLimitCheck] [<CommonParameters>]
Import-PowerShellDataFile [-LiteralPath] <String[]> [-SkipLimitCheck] [<CommonParameters>]
The Import-PowerShellDataFile cmdlet safely imports key-value pairs from hashtables defined in a
.psd1 file. The values could be imported using Invoke-Expression on the contents of the file.
However, Invoke-Expression runs any code contained in the file. This could produce unwanted
results or execute unsafe code. Import-PowerShellDataFile imports the data without invoking the
code.
This example retrieves the key-value pairs stored in the hashtable kept inside the
Configuration.psd1 file. Get-Content is used to show the contents of the Configuration.psd1
file.
Get-Content .\Configuration.psd1
$config = Import-PowerShellDataFile .\Configuration.psd1
$config.AllNodes@{
AllNodes = @(
@{
NodeName = 'DSC-01'
}
@{
NodeName = 'DSC-02'
}
)
}
Name Value
---- -----
NodeName DSC-01
NodeName DSC-02
The path to the file being imported. All characters in the path are treated as literal values. Wildcard characters aren't processed.
Type: System.String[]
Parameter Sets: ByLiteralPath
Aliases: PSPath, LP
Required: True
Position: 0
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: FalseThe path to the file being imported. Wildcards are allowed but only the first matching file is imported.
Type: System.String[]
Parameter Sets: ByPath
Aliases:
Required: True
Position: 0
Default value: None
Accept pipeline input: False
Accept wildcard characters: TrueBy default Import-PowerShellDataFile is limited to 500 keys containing a maximum of 5000 AST
nodes when importing from a .psd1 file. Use SkipLimitCheck to bypass these limits.
Important
You should only bypass the limits if you are sure the file is safe to import. It's possible for a
malicious actor to create a .psd1 file with a large number of keys or AST nodes that could
result in a denial of service.
Type: Switch
Parameter Sets: All
Aliases:
Required: False
Position: 0
Default value: False
Accept pipeline input: False
Accept wildcard characters: FalseThis cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
This cmdlet returns the data from the file as a hash table.