Main | Contact | Blog | Documentation

PowerShell Framework

The project dedicated to empowering your PowerShell scripting.

Import-PSFConfig

SYNOPSIS

Imports a configuration file into the configuration system.

SYNTAX

Path (Default)

Import-PSFConfig -Path <String[]> [-Schema <String>] [-IncludeFilter <String[]>] [-ExcludeFilter <String[]>]
 [-Peek] [-AllowDelete] [-PassThru] [-EnableException] [<CommonParameters>]

ModuleName

Import-PSFConfig -ModuleName <String> [-ModuleVersion <Int32>] [-Scope <ConfigScope>] [-PassThru]
 [-EnableException] [<CommonParameters>]

Environment

Import-PSFConfig [-EnvironmentPrefix <String>] [-Simple] [-PassThru] [-EnableException] [<CommonParameters>]

DESCRIPTION

Imports a configuration file into the configuration system. There are two modes of import:

EXAMPLES

EXAMPLE 1

Import-PSFConfig -Path '.\config.json'

Imports the configuration stored in ‘.\config.json’

EXAMPLE 2

Import-PSFConfig -ModuleName mymodule

Imports all the module specific settings that have been persisted in any of the default file system paths.

PARAMETERS

-Path

The path to the file to import. Ensure the file is properly formatted for the configuration schema specified.

Type: String[]
Parameter Sets: Path
Aliases:

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

-ModuleName

Import configuration items specific to a module from the default configuration paths.

Type: String
Parameter Sets: ModuleName
Aliases:

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

-ModuleVersion

The configuration version of the module-settings to load.

Type: Int32
Parameter Sets: ModuleName
Aliases:

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

-Scope

Where to import the module specific configuration items form. Only file-based scopes are supported for this. By default, all locations are queried, with user settings beating system settings.

Type: ConfigScope
Parameter Sets: ModuleName
Aliases:
Accepted values: UserDefault, UserMandatory, SystemDefault, SystemMandatory, FileUserLocal, FileUserShared, FileSystem, Environment, EnvironmentSimple

Required: False
Position: Named
Default value: FileUserLocal, FileUserShared, FileSystem
Accept pipeline input: False
Accept wildcard characters: False

-Schema

The configuration schema to use for import. Use Register-PSFConfigSchema to extend the way input content can be laid out.

Type: String
Parameter Sets: Path
Aliases:

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

-IncludeFilter

If specified, only elements with names that are similar (-like) to names in this list will be imported.

Type: String[]
Parameter Sets: Path
Aliases:

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

-ExcludeFilter

Elements that are similar (-like) to names in this list will not be imported.

Type: String[]
Parameter Sets: Path
Aliases:

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

-Peek

Rather than applying the setting, return the configuration items that would have been applied.

Type: SwitchParameter
Parameter Sets: Path
Aliases:

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

-AllowDelete

Configurations that have been imported will be flagged as deletable. This allows to purge them at a later time using Remove-PSFConfig.

Type: SwitchParameter
Parameter Sets: Path
Aliases:

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

-EnvironmentPrefix

Import values from environment variables. Entries will be expected to start with the prefix, then an Underscore, then the full name of the configuration setting. Example: PSF_PSFramework.Utility.Size.Digits By default, the same value formatting needs to be adhered to as is in registry settings. For example, to store the number 3, the value would be “Int:3”. Use: (Get-PSFConfig -FullName ‘<name of setting>’).RegistryData To see how an existing setting would look in that format. You can switch to simple mode using the ‘-Simple’ parameter. Which cannot handle complex objects, but has less overhead for simple data types.

Type: String
Parameter Sets: Environment
Aliases:

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

-Simple

Switches the import from environment variables into a simple data mode. In this mode it will only understand a few simple data types, but provide for very simple value formatting:

Type: SwitchParameter
Parameter Sets: Environment
Aliases:

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

-PassThru

Return configuration settings that have been imported. By default, this command will not produce any output.

Type: SwitchParameter
Parameter Sets: (All)
Aliases:

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

-EnableException

This parameters disables user-friendly warnings and enables the throwing of exceptions. This is less user friendly, but allows catching exceptions in calling scripts.

Type: SwitchParameter
Parameter Sets: (All)
Aliases:

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