Skip to content

Commit 72be26f

Browse files
authored
Merge pull request #838 from Icinga:fix/ensure_ifw_never_loads_user_profiles
Fix: Never load user PowerShell profiles To enhance compatibility and reduce the overall impact during certain tasks run by Icinga for Windows, ensure we never load any user PowerShell profiles
2 parents 0c72fda + 44d66a9 commit 72be26f

16 files changed

+28
-22
lines changed

doc/100-General/10-Changelog.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,15 @@ Released closed milestones can be found on [GitHub](https://github.com/Icinga/ic
1111

1212
[Issues and PRs](https://github.com/Icinga/icinga-powershell-framework/milestone/38)
1313

14+
### Bugfixes
15+
1416
* [#835](https://github.com/Icinga/icinga-powershell-framework/pull/835) Fixes JEA compiler to always enforce a rebuild of the Framework to ensure integrity of JEA profiles
1517
* [#836](https://github.com/Icinga/icinga-powershell-framework/issues/836) Fixes Metric over Time collector not working on Windows 2012 R2 and older
1618

19+
### Enhancements
20+
21+
* [#838](https://github.com/Icinga/icinga-powershell-framework/pull/838) Enhances Icinga for Windows to never load and user PowerShell profiles
22+
1723
## 1.13.4 (tbd)
1824

1925
[Issues and PRs](https://github.com/Icinga/icinga-powershell-framework/milestone/42)

doc/130-JEA/02-Installation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ Update-IcingaJEAProfile -IcingaUser 'MyOwnIcingaUser';
8282
If you used `TestEnv` to create a test environment for JEA for the current user, you can simply enter the PowerShell JEA session with this command:
8383

8484
```powershell
85-
powershell.exe -ConfigurationName 'IcingaForWindowsTest';
85+
powershell.exe -NoProfile -ConfigurationName 'IcingaForWindowsTest';
8686
```
8787

8888
This will open a new `remote` PowerShell session over `WinRM` on the local machine with the provided JEA profile 'IcingaForWindowsTest'.

icinga-powershell-framework.psm1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ function Invoke-IcingaCommand()
340340
# Ensure we set the path to another folder to prevent locking the Framework Root Folder
341341
Set-Location (Get-IcingaForWindowsRootPath);
342342

343-
powershell.exe -NoExit -Command {
343+
powershell.exe -NoProfile -NoExit -Command {
344344
$Script = $args[0];
345345
$RootPath = $args[1];
346346
$Version = $args[2];
@@ -427,7 +427,7 @@ function Start-IcingaShellAsUser()
427427
-Verb RunAs `
428428
-ArgumentList (
429429
[string]::Format(
430-
"-Command `"Start-Process -FilePath `"powershell.exe`" -WorkingDirectory `"{0}`" -Credential (Get-Credential -UserName '{1}' -Message 'Please enter your credentials to open an Icinga Shell with') -ArgumentList icinga`"",
430+
"-NoProfile -Command `"Start-Process -FilePath `"powershell.exe`" -WorkingDirectory `"{0}`" -Credential (Get-Credential -UserName '{1}' -Message 'Please enter your credentials to open an Icinga Shell with') -ArgumentList icinga`"",
431431
$PSHOME,
432432
$User
433433
)

lib/core/framework/Install-IcingaFrameworkComponent.psm1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ function Install-IcingaFrameworkComponent()
112112

113113
if ([string]::IsNullOrEmpty((Get-IcingaJEAContext)) -eq $FALSE) {
114114
Write-IcingaConsoleNotice 'Updating Icinga JEA profile';
115-
& powershell.exe -Command { Use-Icinga -Minimal; Install-IcingaJEAProfile; } | Out-Null;
115+
& powershell.exe -NoProfile -Command { Use-Icinga -Minimal; Install-IcingaJEAProfile; } | Out-Null;
116116
}
117117

118118
# Unload the module if it was loaded before

lib/core/framework/Install-IcingaFrameworkUpdate.psm1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ function Install-IcingaFrameworkUpdate()
109109
if ([string]::IsNullOrEmpty((Get-IcingaJEAContext)) -eq $FALSE) {
110110
Remove-IcingaFrameworkDependencyFile;
111111
Write-IcingaConsoleNotice 'Updating Icinga JEA profile';
112-
& powershell.exe -Command { Use-Icinga -Minimal; Install-IcingaJEAProfile; } | Out-Null;
112+
& powershell.exe -NoProfile -Command { Use-Icinga -Minimal; Install-IcingaJEAProfile; } | Out-Null;
113113
}
114114

115115
Write-IcingaConsoleNotice 'Framework update has been completed. Please start a new PowerShell instance now to complete the update';

lib/core/framework/Restart-IcingaService.psm1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ function Restart-IcingaService()
2727
if (Get-Service "$Service" -ErrorAction SilentlyContinue) {
2828
Write-IcingaConsoleNotice ([string]::Format('Restarting service "{0}"', $Service));
2929

30-
& powershell.exe -Command {
30+
& powershell.exe -NoProfile -Command {
3131
Use-Icinga -Minimal;
3232

3333
$Service = $args[0];

lib/core/framework/Start-IcingaService.psm1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ function Start-IcingaService()
2727
if (Get-Service $Service -ErrorAction SilentlyContinue) {
2828
Write-IcingaConsoleNotice -Message 'Starting service "{0}"' -Objects $Service;
2929

30-
& powershell.exe -Command {
30+
& powershell.exe -NoProfile -Command {
3131
Use-Icinga -Minimal;
3232

3333
$Service = $args[0];

lib/core/framework/Stop-IcingaService.psm1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ function Stop-IcingaService()
2727
if (Get-Service "$Service" -ErrorAction SilentlyContinue) {
2828
Write-IcingaConsoleNotice -Message 'Stopping service "{0}"' -Objects $Service;
2929

30-
& powershell.exe -Command {
30+
& powershell.exe -NoProfile -Command {
3131
Use-Icinga -Minimal;
3232

3333
$Service = $args[0];

lib/core/icingaagent/installer/Install-IcingaAgent.psm1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ function Install-IcingaAgent()
7373
}
7474
}
7575

76-
$InstallProcess = & powershell.exe -Command {
76+
$InstallProcess = & powershell.exe -NoProfile -Command {
7777
Use-Icinga -Minimal;
7878

7979
$IcingaInstaller = $args[0];

lib/core/icingaagent/installer/Uninstall-IcingaAgent.psm1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ function Uninstall-IcingaAgent()
2222

2323
Stop-IcingaService -Service 'icinga2';
2424

25-
$Uninstaller = & powershell.exe -Command {
25+
$Uninstaller = & powershell.exe -NoProfile -Command {
2626
Use-Icinga -Minimal;
2727

2828
$IcingaData = $args[0];

0 commit comments

Comments
 (0)