Fixes errors on encapsulated PowerShell calls

This commit is contained in:
Lord Hepipud 2022-06-08 16:48:19 +02:00
parent b85f282f0b
commit 02d1e71032
9 changed files with 17 additions and 2 deletions

View file

@ -14,6 +14,7 @@ Released closed milestones can be found on [GitHub](https://github.com/Icinga/ic
### Bugfixes
* [#529](https://github.com/Icinga/icinga-powershell-framework/pull/529) Fixes package manifest reader for Icinga for Windows components on Windows 2012 R2 and older
* [#523](https://github.com/Icinga/icinga-powershell-framework/pull/523) Fixes errors on encapsulated PowerShell calls for missing Cmdlets `Write-IcingaConsoleError` and `Optimize-IcingaForWindowsMemory`
### Enhancements

View file

@ -112,7 +112,7 @@ function Install-IcingaFrameworkComponent()
if ([string]::IsNullOrEmpty((Get-IcingaJEAContext)) -eq $FALSE) {
Write-IcingaConsoleNotice 'Updating Icinga JEA profile';
& powershell.exe -Command { Use-Icinga; Install-IcingaJEAProfile; } | Out-Null;
& powershell.exe -Command { Use-Icinga -Minimal; Install-IcingaJEAProfile; } | Out-Null;
}
# Unload the module if it was loaded before

View file

@ -109,7 +109,7 @@ function Install-IcingaFrameworkUpdate()
if ([string]::IsNullOrEmpty((Get-IcingaJEAContext)) -eq $FALSE) {
Remove-IcingaFrameworkDependencyFile;
Write-IcingaConsoleNotice 'Updating Icinga JEA profile';
& powershell.exe -Command { Use-Icinga; Install-IcingaJEAProfile; } | Out-Null;
& powershell.exe -Command { Use-Icinga -Minimal; Install-IcingaJEAProfile; } | Out-Null;
}
Write-IcingaConsoleNotice 'Framework update has been completed. Please start a new PowerShell instance now to complete the update';

View file

@ -28,6 +28,8 @@ function Restart-IcingaService()
Write-IcingaConsoleNotice ([string]::Format('Restarting service "{0}"', $Service));
& powershell.exe -Command {
Use-Icinga -Minimal;
$Service = $args[0];
try {
Restart-Service "$Service" -ErrorAction Stop;

View file

@ -28,6 +28,8 @@ function Start-IcingaService()
Write-IcingaConsoleNotice -Message 'Starting service "{0}"' -Objects $Service;
& powershell.exe -Command {
Use-Icinga -Minimal;
$Service = $args[0];
try {
Start-Service "$Service" -ErrorAction Stop;

View file

@ -28,6 +28,8 @@ function Stop-IcingaService()
Write-IcingaConsoleNotice -Message 'Stopping service "{0}"' -Objects $Service;
& powershell.exe -Command {
Use-Icinga -Minimal;
$Service = $args[0];
try {
Stop-Service "$Service" -ErrorAction Stop;

View file

@ -74,6 +74,8 @@ function Install-IcingaAgent()
}
$InstallProcess = & powershell.exe -Command {
Use-Icinga -Minimal;
$IcingaInstaller = $args[0];
$InstallTarget = $args[1];
$InstallProcess = Start-IcingaProcess -Executable 'MsiExec.exe' -Arguments ([string]::Format('/quiet /i "{0}" {1}', $IcingaInstaller.InstallerPath, $InstallTarget)) -FlushNewLines;

View file

@ -23,6 +23,8 @@ function Uninstall-IcingaAgent()
Stop-IcingaService -Service 'icinga2';
$Uninstaller = & powershell.exe -Command {
Use-Icinga -Minimal;
$IcingaData = $args[0];
$Uninstaller = Start-IcingaProcess -Executable 'MsiExec.exe' -Arguments ([string]::Format('{0} /q', $IcingaData.Uninstaller)) -FlushNewLine;

View file

@ -349,6 +349,8 @@ function Install-IcingaComponent()
}
$MSIData = & powershell.exe -Command {
Use-Icinga -Minimal;
$DownloadDestination = $args[0];
return (Read-IcingaMSIMetadata -File $DownloadDestination);
} -Args $DownloadDestination;
@ -369,6 +371,8 @@ function Install-IcingaComponent()
}
$InstallProcess = & powershell.exe -Command {
Use-Icinga -Minimal;
$DownloadDestination = $args[0];
$InstallTarget = $args[1];
$InstallProcess = Start-IcingaProcess -Executable 'MsiExec.exe' -Arguments ([string]::Format('/quiet /i "{0}" {1}', $DownloadDestination, $InstallTarget)) -FlushNewLines;