Configuration powershell script?

Hello.

There is a script written in powershell, what are the options for storing its configuration?
What is more convenient in practice?
June 3rd 19 at 19:08
3 answers
June 3rd 19 at 19:10
Environment variables, registry, config next to the file or profile (as the config you can just put the powershell script with assignment and variables, and to execute it)
June 3rd 19 at 19:12
in practice it will be convenient to use the fact that the native PowerShell can parse.
json clixml, csv and xml part.
June 3rd 19 at 19:14
Example store configuration in xml.
Script
function getConfig ($configFile){
 if (Test-Path ((Get-Location).Path + "\$configFile")){
 $config = ([xml]$(Get-Content $configFile)).configuration
 if ($? -and $config){
 return $config
}
else{
 Write-Host 'Config file is incorrect'
}
}
 else {
 Write-Host 'Config file not found'
 } 
}

function init {
 $files = $configuration.logFiles.File
 foreach ($file in $files){
 New-Item-Path ($(Get-Location).Path + "\Logs\$(Get-Date-Format 'yyyy')\$(Get-Date -Format 'MM')\$(Get-Date -Format 'dd')") -Name $file.value-ItemType File-Force | Out-Null
}
}

$ErrorActionPreference = 'SilentlyContinue'
$configFile = 'config.xml'
$configuration = getConfig ($configFile)
init

Config
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<configuration>
<logfiles>
 <file key="Full" value="logFull.log">
 <file key="Warning" value="logWarning.log">
 <file key="Error" value="logError.log">
</file></file></file></logfiles>
</configuration>

Find more questions by tags PowerShell