Get-Configuration Powershell. , , ( JSON) .
(dir env:PSGetConfiguration).Value
{
"Mode": "Xml",
"XmlPath": "C:\\Managers\\PSGetConfiguration.xml"
}
cat $(Get-ConfigurationSource).XmlPath
<Configuration>
<conf key="ExampleKey" value="ExampleValue" />
<conf key="key" value="Value123" />
<conf key="remove" value="remove" />
</Configuration>
Get-Configuration Set-Configuration
Set-Configuration -Key k1 -Value v1
Get-Configuration -Key k1
v1

When the module starts, XML is saved in the module directory, it can be changed by manually changing the environment variable or using the Set-XmlConfigurationSource command
SQL configuration
By default, the module uses XML to store data, but the second option is to store data in SQL. Setting up the configuration is quite simple:
Set-SqlConfigurationSource -SqlServerInstance ".\sql2017" -SqlServerDatabase "ConfigDatabase" -SqlServerSchema "config" -SqlServerTable "Configuration"
After that, our config will be saved in the SQL table.

Code is also available on github .
source
share