Public/Get-mssConfig.TempPoint.ps1
|
<#
.SYNOPSIS Gibt die aktuelle Modulkonfiguration zurück. .DESCRIPTION Ohne Parameter wird die gesamte Konfiguration als Hashtable zurückgegeben. Mit -Key wird der Wert des angeforderten Schlüssels geliefert. Existiert der Schlüssel nicht, erscheint eine Warnung und es wird $null zurückgegeben. .PARAMETER Key Name des Konfigurationsschlüssels (z. B. 'LogPath', 'OutputPath', 'CentralPath'). .EXAMPLE Get-mssConfig .EXAMPLE Get-mssConfig -Key 'OutputPath' #> # Modulkonfiguration (wird beim Laden des Moduls gesetzt) $script:mssModuleConfig = @{ LogPath = "C:\system\WinSrvLog\MSSQL" OutputPath = "C:\System\WinSrvLog\MSSQL" CentralPath = "C:\System\WinSrvLog\MSSQL" } function Get-mssConfig { [CmdletBinding()] param ( [Parameter(Mandatory = $false)] [string]$Key ) if ($Key) { if ($script:mssModuleConfig.ContainsKey($Key)) { return $script:mssModuleConfig[$Key] } else { Write-Warning "Konfigurationsschlüssel '$Key' existiert nicht. Verfügbare Schlüssel: $($script:mssModuleConfig.Keys -join ', ')" return $null } } return $script:mssModuleConfig } |