Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/100-General/10-Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Released closed milestones can be found on [GitHub](https://github.com/Icinga/ic

### Bugfixes

* [#578](https://github.com/Icinga/icinga-powershell-framework/issues/578) Fixes installation and uninstallation commands changing PowerShell location even when not necessary
* [#582](https://github.com/Icinga/icinga-powershell-framework/issues/582) Fixes background service registration caused by migration task for v1.10.0 being executed even when no services were defined before
* [#588](https://github.com/Icinga/icinga-powershell-framework/issues/588) Fixes threshold values causing an error because of too aggressive regex expression
* [#599](https://github.com/Icinga/icinga-powershell-plugins/issues/599) Fixes plugin argument parser to proceed with real argument names and possible provided aliases
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ function Write-IcingaForWindowsComponentCompilationFile()
[string]$CompiledFilePath = ''
);

# Store our current shell location
[string]$OldLocation = Get-Location;
# Get the current location and leave this folder
Set-Location -Path $ScriptRootPath;
Set-Location -Path '..';
Expand Down Expand Up @@ -57,4 +59,7 @@ function Write-IcingaForWindowsComponentCompilationFile()

Import-Module -Name $ModulePath -Force;
Import-Module -Name $ModulePath -Force -Global;

# Set our location back to the previous folder
Set-Location -Path $OldLocation;
}
2 changes: 1 addition & 1 deletion lib/core/framework/Uninstall-IcingaForWindows.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ function Uninstall-IcingaForWindows()
}
}

Set-Location -Path (Get-IcingaForWindowsRootPath);
Set-IcingaPSLocation;

Write-IcingaConsoleNotice 'Uninstalling Icinga for Windows from this host';
Write-IcingaConsoleNotice 'Uninstalling Icinga Security configuration if applied';
Expand Down
4 changes: 2 additions & 2 deletions lib/core/repository/Uninstall-IcingaComponent.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ function Uninstall-IcingaComponent()
}

# Set our current location to the PowerShell modules folder, to prevent possible folder lock during uninstallation
Set-Location (Get-IcingaForWindowsRootPath);
Set-IcingaPSLocation -Path $UninstallPath;

Write-IcingaConsoleNotice -Message 'Uninstalling Icinga for Windows component "{0}" from "{1}"' -Objects $UninstallComponent, $UninstallPath;
if (Remove-ItemSecure -Path $UninstallPath -Recurse -Force) {
Write-IcingaConsoleNotice -Message 'Successfully removed Icinga for Windows component "{0}" from "{1}"' -Objects $UninstallComponent, $UninstallPath;
if ($UninstallComponent -ne 'icinga-powershell-framework') {
Remove-Module $UninstallComponent -Force -ErrorAction SilentlyContinue;
# In case we are not removing the framework itself, set the location to the Icinga for Windows Folder
Set-Location (Get-IcingaFrameworkRootPath);
Set-IcingaPSLocation -Path $UninstallPath;
}
return $TRUE;
} else {
Expand Down
21 changes: 21 additions & 0 deletions lib/core/tools/Set-IcingaPSLocation.psm1
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
function Set-IcingaPSLocation()
{
param (
[string]$Path = (Get-Location)
);

if ([string]::IsNullOrEmpty($Path)) {
return;
}

if ((Test-Path $Path) -eq $FALSE) {
return;
}

[string]$IfWRootPath = Get-IcingaForWindowsRootPath;
[string]$CurrentPath = Get-Location;

if ($CurrentPath -Like ([string]::Format('{0}*', $Path))) {
Set-Location -Path $IfWRootPath;
}
}