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
2 changes: 1 addition & 1 deletion doc/100-General/01-Upgrading.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Otherwise the service will not start and crash! You can either download the serv
Update-Icinga -Name 'service';
```

After upgrading to Icinga for Windows v1.8.0, you will require to open a new Icinga shell by calling `icinga` or by using `Use-Icinga` once, to run the new migration process.
After upgrading to Icinga for Windows v1.8.0, you will require to open a new Icinga shell by calling `icinga -Shell` or simply `icinga` to open the IMC for running the migration tasks.

**NOTE:** In some cases the changes for the EventLog will only apply, **after** the system has been rebooted. Afterwards every Icinga for Windows EventLog entry is written in a newly created `Icinga for Windows` log.

Expand Down
1 change: 1 addition & 0 deletions doc/100-General/10-Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ Released closed milestones can be found on [GitHub](https://github.com/Icinga/ic
* [#445](https://github.com/Icinga/icinga-powershell-framework/pull/445) Adds command `Repair-IcingaService` to repair Icinga Agent service in case it was broken during upgrades, mostly caused by `The specified service has been marked for deletion`
* [#448](https://github.com/Icinga/icinga-powershell-framework/pull/448) Adds support to sort arrays without ScriptBlocks
* [#450](https://github.com/Icinga/icinga-powershell-framework/pull/450) Improves show command `Show-IcingaRegisteredServiceChecks`, adds new command `Show-IcingaRegisteredBackgroundDaemons` and extends `Show-Icinga` by both commands and adds debug and api forwarder features to environment list
* [#453](https://github.com/Icinga/icinga-powershell-framework/pull/453) Reworks Icinga Management Console menu structure and naming and changes the default behavior of executing `icinga` to now open the IMC by default and `icinga -Shell` to open a shell as done previously
* [#455](https://github.com/Icinga/icinga-powershell-framework/pull/455) Adds support for remote execution plugin [check_by_icingaforwindows](https://github.com/LordHepipud/check_by_icingaforwindows)

## 1.7.1 (2021-11-11)
Expand Down
2 changes: 1 addition & 1 deletion doc/110-Installation/02-Icinga-Management-Console.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ As we now have deployed our Icinga PowerShell Framework on our Windows machine,
**Note:** You can always open the IMC by running the following command:

```powershell
icinga -Manage;
icinga;
```

## Navigating the IMC
Expand Down
2 changes: 1 addition & 1 deletion doc/110-Installation/03-Installation-with-IMC.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ We can now use the Icinga Management Console to configure our local Windows syst
If we are not already inside the IMC, we can open it with

```powershell
icinga -Manage;
icinga;
```

## Installation menu
Expand Down
2 changes: 1 addition & 1 deletion doc/160-Features/04-Manage-Icinga-Agent-Features.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

The Icinga PowerShell Framework is shipping wish a bunch of Cmdlets to manage the Icinga Agent in a very easy way. This includes the managing for features enabled or disabled for the Icinga Agent.

**Note:** Before using any of the commands below you will have to initialize the Icinga PowerShell Framework inside a new PowerShell instance with `Use-Icinga`. Starting with version `1.2.0` of the Framework you can also simply type `icinga` into the command line.
**Note:** Before using any of the commands below you will have to initialize the Icinga PowerShell Framework inside a new PowerShell instance with `icinga -Shell`

## List Icinga Agent Features

Expand Down
2 changes: 1 addition & 1 deletion doc/160-Features/05-Read-Icinga-Agent-Logs.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

The Icinga PowerShell Framework is shipping wish a bunch of Cmdlets to manage the Icinga Agent in a very easy way. This includes reading the Icinga Agent log/debug log file.

**Note:** Before using any of the commands below you will have to initialize the Icinga PowerShell Framework inside a new PowerShell instance with `Use-Icinga`. Starting with version `1.2.0` of the Framework you can also simply type `icinga` into the command line.
**Note:** Before using any of the commands below you will have to initialize the Icinga PowerShell Framework inside a new PowerShell instance with `icinga -Shell`

## Read the default Icinga Agent log file

Expand Down
8 changes: 4 additions & 4 deletions doc/160-Features/06-Test-Icinga-Installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

The Icinga PowerShell Framework is shipping wish a bunch of Cmdlets to manage the Icinga Agent in a very easy way. This includes a test for the entire configuration and state of the Icinga Agent on the machine.

**Note:** Before using any of the commands below you will have to initialize the Icinga PowerShell Framework inside a new PowerShell instance with `Use-Icinga`. Starting with version `1.2.0` of the Framework you can also simply type `icinga` into the command line.
**Note:** Before using any of the commands below you will have to initialize the Icinga PowerShell Framework inside a new PowerShell instance with `icinga -Shell`

## Testing for errors

A very important part of an Agent is to ensure that it is running properly and no configuration error is present. In addition it is important that required directories are accessable by the service user the Icinga Agent is running with. For this you can use the Cmdlet `Test-IcingaAgent`:
A very important part of an Agent is to ensure that it is running properly and no configuration error is present. In addition it is important that required directories are accessible by the service user the Icinga Agent is running with. For this you can use the Cmdlet `Test-IcingaAgent`:

```powershell
Test-IcingaAgent;
Expand Down Expand Up @@ -51,7 +51,7 @@ In addition for testing, the Icinga PowerShell Framework will suggest methods to
[Passed]: Icinga Agent debug log is disabled
```

As you can see, the mandatory directory `C:\ProgramData\icinga2\var` is not accessable by our `NT AUTHORITY\NetworkService` user. To resolve this, the Framework provides the Cmdlet `Set-IcingaAcl`. It will automatically set the correct permissions for a specific directory for the service user the Icinga Agent is running with:
As you can see, the mandatory directory `C:\ProgramData\icinga2\var` is not accessible by our `NT AUTHORITY\NetworkService` user. To resolve this, the Framework provides the Cmdlet `Set-IcingaAcl`. It will automatically set the correct permissions for a specific directory for the service user the Icinga Agent is running with:

```powershell
Set-IcingaAcl -Directory 'C:\ProgramData\icinga2\var';
Expand Down Expand Up @@ -97,7 +97,7 @@ As our configuration is for some reason broken we have to resolve this. The Icin
Test-IcingaAgentConfig -WriteStackTrace | Out-Null;
```

By using the argument `-WriteStackTrace` we will print the actual error ouptut from the Icinga Agent binary to our console for troubleshooting:
By using the argument `-WriteStackTrace` we will print the actual error output from the Icinga Agent binary to our console for troubleshooting:

```text
[2020-08-12 16:54:26 +0200] information/cli: Icinga application loader (version: v2.12.0)
Expand Down
2 changes: 1 addition & 1 deletion doc/160-Features/20-Change-Icinga-Service-User.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

The Icinga PowerShell Framework is shipping wish a bunch of Cmdlets to manage the Icinga Agent in a very easy way. This includes changing the current assigned Service User of the Icinga Agent to another one.

**Note:** Before using any of the commands below you will have to initialize the Icinga PowerShell Framework inside a new PowerShell instance with `Use-Icinga`. Starting with version `1.2.0` of the Framework you can also simply type `icinga` into the command line.
**Note:** Before using any of the commands below you will have to initialize the Icinga PowerShell Framework inside a new PowerShell instance with `icinga -Shell`

## Getting started

Expand Down
12 changes: 2 additions & 10 deletions doc/900-Developer-Guide/52-Testing-of-Commands.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
# Developer Guide: Testing of Commands

Actively developing new code for the Framework will result in core files to be changed or new functionality added. To load the Framework we use in general `Use-Icinga`, which does how ever not cover changes we made afterwards. To keep track of the changes for new features or while testing something, we always have to open a new PowerShell instance.

To make things more usable, we can of course run a PowerShell command directly from our shell:

```powershell
powershell -C { Use-Icinga; <# your code #> }
```

While this is straight forward and easy to use, the idea is to make this way simpler.
Actively developing new code for the Framework will result in core files to be changed or new functionality added. To load the Framework we use in general `icinga -Shell`, which does how ever not cover changes we made afterwards. To keep track of the changes for new features or while testing something, we always have to open a new PowerShell instance.

## Invoke-IcingaCommand or simply icinga

Expand Down Expand Up @@ -58,7 +50,7 @@ icinga> Exit-IcingaThrowException -Force -CustomMessage 'Force Exit of our Shell
Unhandled exception occured:
```

Instead of our own shell closing, we still have our previous one open and can start another shell by using `icinga` with the entire Framework loaded.
Instead of our own shell closing, we still have our previous one open and can start another shell by using `icinga -Shell` with the entire Framework loaded.

This also works for code we directly invoke to the `icinga` alias:

Expand Down
2 changes: 1 addition & 1 deletion doc/950-Deprecated/04-Icinga-Agent-Wizard.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ To start the Icinga Agent installation wizard you will have to open a PowerShell
Use-Icinga
```

*Note:* Starting with Icinga PowerShell Framework `1.2.0` you can simply type `icinga` to open an Icinga PowerShell Framework shell,
*Note:* Starting with Icinga PowerShell Framework `1.2.0` you can simply type `icinga -Shell` to open an Icinga PowerShell Framework shell,

Once the command is executed, the Framework and all required components are loaded. To get started, we can now run

Expand Down
2 changes: 1 addition & 1 deletion doc/frameworkusage/34-Uninstall-Icinga-Agent.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

While the main purpose of the Icinga for Windows solution is check your systems and provided all required tools, including the Icinga Agent, it might be required to entirely uninstall the Icinga Agent. This sometimes might even include to flush the entire `ProgramData` folder, where certificates and other configurations are stored.

**Note:** Before using any of the commands below you will have to initialize the Icinga PowerShell Framework inside a new PowerShell instance with `Use-Icinga`. Starting with version `1.2.0` of the Framework you can also simply type `icinga` into the command line.
**Note:** Before using any of the commands below you will have to initialize the Icinga PowerShell Framework inside a new PowerShell instance with `icinga -Shell`

## Uninstalling the Icinga Agent

Expand Down
2 changes: 1 addition & 1 deletion doc/frameworkusage/35-Install-Update-Icinga-Agent.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Managing the Icinga Agent is one of the main goals for Icinga for Windows. This also includes installing and updating the Icinga Agent itself.

**Note:** Before using any of the commands below you will have to initialize the Icinga PowerShell Framework inside a new PowerShell instance with `Use-Icinga`. Starting with version `1.2.0` of the Framework you can also simply type `icinga` into the command line.
**Note:** Before using any of the commands below you will have to initialize the Icinga PowerShell Framework inside a new PowerShell instance with `icinga -Shell`

## Installing the Icinga Agent

Expand Down
2 changes: 1 addition & 1 deletion doc/knowledgebase/IWKB000001.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ There is a detailed description on the [Microsoft Docs](https://docs.microsoft.c

#### Using PowerShell

To add permissions for WMI namespaces you can use our Icinga for Windows Cmdlets. Simply open a new PowerShell as `Administrator` and create a new Icinga Shell instance by typing `icinga`.
To add permissions for WMI namespaces you can use our Icinga for Windows Cmdlets. Simply open a new PowerShell as `Administrator` and create a new Icinga Shell instance by typing `icinga -Shell`.
After the Icinga PowerShell Framework is loaded, we can use our Wmi permission Cmdlet:

```powershell
Expand Down
2 changes: 1 addition & 1 deletion icinga-powershell-framework.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
GUID = 'fcd7a805-a41b-49f9-afee-9d17a2b76d42'
Author = 'Lord Hepipud'
CompanyName = 'Icinga GmbH'
Copyright = '(c) 2021 Icinga GmbH | MIT'
Copyright = '(c) 2022 Icinga GmbH | MIT'
Description = 'Icinga for Windows module which allows to entirely monitor the Windows Host system.'
PowerShellVersion = '4.0'
NestedModules = @( '.\cache\framework_cache.psm1' )
Expand Down
13 changes: 7 additions & 6 deletions icinga-powershell-framework.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,8 @@ function Invoke-IcingaCommand()
param (
$ScriptBlock,
[switch]$SkipHeader = $FALSE,
[switch]$Manage = $FALSE,
[switch]$Manage = $FALSE, # Only for backwards compatibility, has no use at all
[switch]$Shell = $FALSE,
[switch]$RebuildCache = $FALSE,
[array]$ArgumentList = @()
);
Expand All @@ -191,7 +192,7 @@ function Invoke-IcingaCommand()

# Print a header informing our user that loaded the Icinga Framework with a specific
# version. We can also skip the header by using $SKipHeader
if ([string]::IsNullOrEmpty($ScriptBlock) -And $SkipHeader -eq $FALSE -And $Manage -eq $FALSE) {
if ([string]::IsNullOrEmpty($ScriptBlock) -And $SkipHeader -eq $FALSE -And $Shell) {
[array]$Headers = @(
'Icinga for Windows $FrameworkVersion',
'Copyright $Copyright',
Expand All @@ -209,7 +210,7 @@ function Invoke-IcingaCommand()
Write-IcingaFrameworkCodeCache;
}

if ($Manage -And $null -ne $psISE) {
if ($null -ne $psISE) {
Use-Icinga;
Write-IcingaConsoleError -Message 'Icinga for Windows was loaded, but the Icinga Management Console is not available within the PowerShell ISE context. Please start a regular PowerShell to use it.';
return;
Expand All @@ -224,7 +225,7 @@ function Invoke-IcingaCommand()
$Script = $args[0];
$RootPath = $args[1];
$Version = $args[2];
$Manage = $args[3];
$Shell = $args[3];
$IcingaShellArgs = $args[4];

# Load our Icinga Framework
Expand All @@ -235,7 +236,7 @@ function Invoke-IcingaCommand()
# Set the location to the Icinga Framework module folder
Set-Location $RootPath;

if ($Manage) {
if ($Shell -eq $FALSE -And [string]::IsNullOrEmpty($Script)) {
Install-Icinga;
exit $LASTEXITCODE;
}
Expand All @@ -253,7 +254,7 @@ function Invoke-IcingaCommand()
return "> "
}

} -Args $ScriptBlock, $PSScriptRoot, $IcingaFrameworkData.PrivateData.Version, ([bool]$Manage), $ArgumentList;
} -Args $ScriptBlock, $PSScriptRoot, $IcingaFrameworkData.PrivateData.Version, ([bool]$Shell), $ArgumentList;
}

function Start-IcingaShellAsUser()
Expand Down
23 changes: 17 additions & 6 deletions lib/core/framework/Uninstall-IcingaForWindows.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
"icinga", you require to specify the user to remove it entirely
.PARAMETER Force
Suppress the question if you are sure to uninstall everything
.PARAMETER ComponentsOnly
Only uninstalls components like Icinga Agent, plugins, and so on and keeps the Framework
.INPUTS
System.String
.OUTPUTS
Expand All @@ -27,8 +29,9 @@
function Uninstall-IcingaForWindows()
{
param (
$IcingaUser = 'icinga',
[switch]$Force = $FALSE
$IcingaUser = 'icinga',
[switch]$Force = $FALSE,
[switch]$ComponentsOnly = $FALSE
);

$ModuleList = Get-Module 'icinga-powershell-*' -ListAvailable;
Expand All @@ -53,15 +56,21 @@ function Uninstall-IcingaForWindows()
Uninstall-IcingaSecurity -IcingaUser $IcingaUser;
Write-IcingaConsoleNotice 'Uninstalling Icinga Agent';
Uninstall-IcingaAgent -RemoveDataFolder | Out-Null;
Write-IcingaConsoleNotice 'Uninstalling Icinga for Windows EventLog';
Unregister-IcingaEventLog;
if ($ComponentsOnly -eq $FALSE) {
Write-IcingaConsoleNotice 'Uninstalling Icinga for Windows EventLog';
Unregister-IcingaEventLog;
}
Write-IcingaConsoleNotice 'Uninstalling Icinga for Windows service';
Uninstall-IcingaForWindowsService | Out-Null;

$HasErrors = $FALSE;

foreach ($module in $ModuleList.Name) {
[string]$ModuleName = $module.Replace('icinga-powershell-', '');
[string]$ModuleName = $module.Replace('icinga-powershell-', '').ToLower();

if ($ModuleName -eq 'framework' -And $ComponentsOnly) {
continue;
}

if ((Uninstall-IcingaFrameworkComponent -Name $ModuleName)) {
continue;
Expand All @@ -70,7 +79,9 @@ function Uninstall-IcingaForWindows()
$HasErrors = $TRUE;
}

Remove-Module 'icinga-powershell-framework' -Force -ErrorAction SilentlyContinue;
if ($ComponentsOnly -eq $FALSE) {
Remove-Module 'icinga-powershell-framework' -Force -ErrorAction SilentlyContinue;
}

if ($HasErrors) {
Write-Host 'Not all components could be removed. Please ensure no other PowerShell/Application is currently open and accessing Icinga for Windows files';
Expand Down
Loading