Merge pull request #553 from Icinga:fix/exception_for_service_recovery_for_uninstalled_services

Fix: Exception for service recovery if service was not installed

Fixes an exception caused by service recovery setting, if the required service was not installed before.
This commit is contained in:
Lord Hepipud 2022-08-23 16:39:02 +02:00 committed by GitHub
commit 0756b47128
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 4 deletions

View file

@ -22,6 +22,7 @@ Released closed milestones can be found on [GitHub](https://github.com/Icinga/ic
* [#524](https://github.com/Icinga/icinga-powershell-framework/issues/524) Fixes uninstallation process by improving the location handling of PowerShell instances with Icinga IMC or Shell
* [#545](https://github.com/Icinga/icinga-powershell-framework/issues/545) Fixes `RemoteSource` being cleared within repository `.json` files during `Update-IcingaRepository` tasks
* [#552](https://github.com/Icinga/icinga-powershell-framework/pull/552) Fixes file encoding for Icinga for Windows v1.10.0 to ensure the cache is always properly created with the correct encoding
* [#553](https://github.com/Icinga/icinga-powershell-framework/pull/553) Fixes an exception caused by service recovery setting, if the required service was not installed before
### Enhancements

View file

@ -1,6 +1,6 @@
function Disable-IcingaServiceRecovery()
{
if ($null -ne (Get-Service 'icinga2')) {
if ($null -ne (Get-Service 'icinga2' -ErrorAction SilentlyContinue)) {
$ServiceStatus = Start-IcingaProcess -Executable 'sc.exe' -Arguments 'failure icinga2 reset=0 actions=none/0/none/0/none/0';
if ($ServiceStatus.ExitCode -ne 0) {
@ -10,7 +10,7 @@ function Disable-IcingaServiceRecovery()
}
}
if ($null -ne (Get-Service 'icingapowershell')) {
if ($null -ne (Get-Service 'icingapowershell' -ErrorAction SilentlyContinue)) {
$ServiceStatus = Start-IcingaProcess -Executable 'sc.exe' -Arguments 'failure icingapowershell reset=0 actions=none/0/none/0/none/0';
if ($ServiceStatus.ExitCode -ne 0) {

View file

@ -1,6 +1,6 @@
function Enable-IcingaServiceRecovery()
{
if ($null -ne (Get-Service 'icinga2')) {
if ($null -ne (Get-Service 'icinga2' -ErrorAction SilentlyContinue)) {
$ServiceStatus = Start-IcingaProcess -Executable 'sc.exe' -Arguments 'failure icinga2 reset=0 actions=restart/0/restart/0/restart/0';
if ($ServiceStatus.ExitCode -ne 0) {
@ -10,7 +10,7 @@ function Enable-IcingaServiceRecovery()
}
}
if ($null -ne (Get-Service 'icingapowershell')) {
if ($null -ne (Get-Service 'icingapowershell' -ErrorAction SilentlyContinue)) {
$ServiceStatus = Start-IcingaProcess -Executable 'sc.exe' -Arguments 'failure icingapowershell reset=0 actions=restart/0/restart/0/restart/0';
if ($ServiceStatus.ExitCode -ne 0) {