Skip to content

kakkun61/powershell-config

Repository files navigation

powershell-config

GitHub Actions: test GitHub Actions: install GitHub Actions: lint PowerShell Gallery Sponsor

This is a configuration module for PowerShell. This finds configuration files, read them and convert them to Hashtables.

Specifications

This module treats three types of configurations:

  • local configuration
  • user global configuration
  • system global configuration

Local configuration

A local configuration is named $appname.yaml and located at the current working directory or its parents recursively.

User global configuration

A user global configuration is named config.yaml and located at $Env:APPDATA\$appname.

System global configuration

A system global configuration is named config.yaml and located at $Env:ProgramData\$appname.

Overwriting

When the configurations have the same keys, upper ones overwrite.

For example there are following configurations:

# local configuration
foo: foo

# user global configuration
bar: bar

# system global configuration
bar: buzz

you get:

foo: foo
bar: bar

bar: buzz is overwritten.

Examples

Local configuration

When .\foo.yaml is:

foo: 1
bar: hello
buzz:
 - one
 - two

call:

> Get-Config foo

Name                           Value
----                           -----
bar                            hello
foo                            1
buzz                           {one, two}