From 4b87a68b588939a64d922ad14064557198c65ec3 Mon Sep 17 00:00:00 2001 From: Christian Stein Date: Thu, 12 Dec 2019 16:00:39 +0100 Subject: [PATCH] Add Cmdlets to Show / Remove SelfService Api Key Fixes #35 --- .../tools/Remove-IcingaDirectorSelfServiceKey.psm1 | 14 ++++++++++++++ .../tools/Show-IcingaDirectorSelfServiceKey.psm1 | 11 +++++++++++ 2 files changed, 25 insertions(+) create mode 100644 lib/core/tools/Remove-IcingaDirectorSelfServiceKey.psm1 create mode 100644 lib/core/tools/Show-IcingaDirectorSelfServiceKey.psm1 diff --git a/lib/core/tools/Remove-IcingaDirectorSelfServiceKey.psm1 b/lib/core/tools/Remove-IcingaDirectorSelfServiceKey.psm1 new file mode 100644 index 0000000..6f30b34 --- /dev/null +++ b/lib/core/tools/Remove-IcingaDirectorSelfServiceKey.psm1 @@ -0,0 +1,14 @@ +function Remove-IcingaDirectorSelfServiceKey() +{ + $Path = 'IcingaDirector.SelfService.ApiKey'; + $Value = Get-IcingaPowerShellConfig $Path; + if ($null -ne $Value) { + Remove-IcingaPowerShellConfig 'IcingaDirector.SelfService.ApiKey'; + $Value = Get-IcingaPowerShellConfig $Path; + if ($null -eq $Value) { + Write-Host 'Icinga Director Self-Service Api key was successfully removed. Please dont forget to drop it within the Icinga Director as well'; + } + } else { + Write-Host 'There is no Self-Service Api key configured on this system'; + } +} diff --git a/lib/core/tools/Show-IcingaDirectorSelfServiceKey.psm1 b/lib/core/tools/Show-IcingaDirectorSelfServiceKey.psm1 new file mode 100644 index 0000000..806ad98 --- /dev/null +++ b/lib/core/tools/Show-IcingaDirectorSelfServiceKey.psm1 @@ -0,0 +1,11 @@ +function Show-IcingaDirecorSelfServiceKey() +{ + $Path = 'IcingaDirector.SelfService.ApiKey'; + $Value = Get-IcingaPowerShellConfig $Path; + + if ($null -ne $Value) { + Write-Host ([string]::Format('Self-Service Key: "{0}"', $Value)); + } else { + Write-Host 'There is no Self-Service Api key configured on this system'; + } +}