mirror of
https://github.com/Icinga/icinga-powershell-framework.git
synced 2025-12-20 23:00:35 -05:00
Fixes non string values for file writer
This commit is contained in:
parent
1241c58909
commit
c7ff7f14ad
1 changed files with 12 additions and 0 deletions
|
|
@ -9,6 +9,18 @@ function Write-IcingaFileSecure()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($null -eq $Value) {
|
||||||
|
$Value = '';
|
||||||
|
} elseif ($Value.GetType().Name.ToLower() -eq 'hashtable') {
|
||||||
|
$Value = ConvertTo-Json -InputObject $Value -Depth 100;
|
||||||
|
} elseif (([string]($Value.GetType().BaseType)).ToLower() -eq 'array') {
|
||||||
|
$Value = $Value | Out-String;
|
||||||
|
} elseif ($Value.GetType().Name.ToLower() -eq 'pscustomobject') {
|
||||||
|
$Value = ConvertTo-Json -InputObject $Value -Depth 100;
|
||||||
|
} else {
|
||||||
|
$Value = $Value | Out-String;
|
||||||
|
}
|
||||||
|
|
||||||
if ((Test-Path $File) -eq $FALSE) {
|
if ((Test-Path $File) -eq $FALSE) {
|
||||||
try {
|
try {
|
||||||
New-Item -ItemType File -Path $File -ErrorAction Stop | Out-Null;
|
New-Item -ItemType File -Path $File -ErrorAction Stop | Out-Null;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue