2020-05-13 10:53:15 -04:00
|
|
|
<#
|
|
|
|
|
.SYNOPSIS
|
|
|
|
|
Default Cmdlet for printing error messages to console
|
|
|
|
|
.DESCRIPTION
|
|
|
|
|
Default Cmdlet for printing error messages to console
|
|
|
|
|
.FUNCTIONALITY
|
|
|
|
|
Default Cmdlet for printing error messages to console
|
|
|
|
|
.EXAMPLE
|
|
|
|
|
PS>Write-IcingaConsoleError -Message 'Test message: {0}' -Objects 'Hello World';
|
|
|
|
|
.PARAMETER Message
|
2022-01-14 16:18:59 -05:00
|
|
|
The message to print with {x} placeholder replaced by content inside the Objects array. Replace x with the
|
2020-05-13 10:53:15 -04:00
|
|
|
number of the index from the objects array
|
|
|
|
|
.PARAMETER Objects
|
|
|
|
|
An array of objects being added to a provided message. The index of the array position has to refer to the
|
|
|
|
|
message locations.
|
2022-01-14 16:18:59 -05:00
|
|
|
.PARAMETER DropMessage
|
|
|
|
|
Allows to programmatically drop a message in case it is not required without dealing with If-Blocks
|
2020-05-13 10:53:15 -04:00
|
|
|
.INPUTS
|
|
|
|
|
System.String
|
|
|
|
|
.LINK
|
|
|
|
|
https://github.com/Icinga/icinga-powershell-framework
|
|
|
|
|
#>
|
|
|
|
|
|
|
|
|
|
function Write-IcingaConsoleError()
|
|
|
|
|
{
|
|
|
|
|
param (
|
|
|
|
|
[string]$Message,
|
2021-09-09 12:53:48 -04:00
|
|
|
[array]$Objects,
|
|
|
|
|
[switch]$DropMessage = $FALSE
|
2020-05-13 10:53:15 -04:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
Write-IcingaConsoleOutput `
|
|
|
|
|
-Message $Message `
|
|
|
|
|
-Objects $Objects `
|
|
|
|
|
-ForeColor 'Red' `
|
2021-09-09 12:53:48 -04:00
|
|
|
-Severity 'Error' `
|
|
|
|
|
-DropMessage:$DropMessage;
|
2020-05-13 10:53:15 -04:00
|
|
|
}
|