mirror of
https://github.com/Icinga/icinga-powershell-framework.git
synced 2025-12-21 15:19:58 -05:00
24 lines
659 B
PowerShell
24 lines
659 B
PowerShell
|
|
function Read-IcingaPowerShellConfig()
|
||
|
|
{
|
||
|
|
$ConfigDir = Get-IcingaPowerShellConfigDir;
|
||
|
|
$ConfigFile = Join-Path -Path $ConfigDir -ChildPath 'config.json';
|
||
|
|
|
||
|
|
if ($global:IcingaDaemonData.FrameworkRunningAsDaemon) {
|
||
|
|
if ($global:IcingaDaemonData.ContainsKey('Config')) {
|
||
|
|
return $global:IcingaDaemonData.Config;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
if (-Not (Test-Path $ConfigFile)) {
|
||
|
|
return (New-Object -TypeName PSOBject);
|
||
|
|
}
|
||
|
|
|
||
|
|
[string]$Content = Get-Content -Path $ConfigFile;
|
||
|
|
|
||
|
|
if ([string]::IsNullOrEmpty($Content)) {
|
||
|
|
return (New-Object -TypeName PSOBject);
|
||
|
|
}
|
||
|
|
|
||
|
|
return (ConvertFrom-Json -InputObject $Content);
|
||
|
|
}
|