From 33caeb7ce674539b0067778b3bfc5cd7b485eab1 Mon Sep 17 00:00:00 2001 From: Lord Hepipud Date: Thu, 19 Nov 2020 13:41:23 +0100 Subject: [PATCH] Feature: Allow sharing of local variables with Icinga Shell Fixes #121 --- doc/31-Changelog.md | 1 + icinga-powershell-framework.psm1 | 12 +++++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/doc/31-Changelog.md b/doc/31-Changelog.md index aae0a85..a1eb252 100644 --- a/doc/31-Changelog.md +++ b/doc/31-Changelog.md @@ -13,6 +13,7 @@ Released closed milestones can be found on [GitHub](https://github.com/Icinga/ic ### Enhancements +* [#121](https://github.com/Icinga/icinga-powershell-framework/issues/121) Adds feature allowing sharing of local variables with Icinga Shell, by using `-ArgumentList`. They can then be accessed by using `$IcingaShellArgs` with the correct array index id, following the order of items added to `-ArgumentList` * [#136](https://github.com/Icinga/icinga-powershell-framework/pull/136) Adds support to ignore empty check packages and return `Ok` instead of `Unknown` if `-IgnoreEmptyPackage` is set on `New-IcingaCheckPackage` * [#137](https://github.com/Icinga/icinga-powershell-framework/issues/137) Adds Cmdlet to compare a DateTime object with the current DateTime and return the offset as Integer in seconds * [#139](https://github.com/Icinga/icinga-powershell-framework/pull/139) Add Cmdlet `Start-IcingaShellAsUser` to open an Icinga Shell as different user for testing diff --git a/icinga-powershell-framework.psm1 b/icinga-powershell-framework.psm1 index 77b9c61..a283d9a 100644 --- a/icinga-powershell-framework.psm1 +++ b/icinga-powershell-framework.psm1 @@ -314,7 +314,8 @@ function Invoke-IcingaCommand() [CmdletBinding()] param ( $ScriptBlock, - [switch]$SkipHeader = $FALSE + [switch]$SkipHeader = $FALSE, + [array]$ArgumentList = @() ); Import-LocalizedData ` @@ -336,9 +337,10 @@ function Invoke-IcingaCommand() } powershell.exe -NoExit -Command { - $Script = $args[0]; - $RootPath = $args[1]; - $Version = $args[2]; + $Script = $args[0]; + $RootPath = $args[1]; + $Version = $args[2]; + $IcingaShellArgs = $args[3]; # Load our Icinga Framework Use-Icinga; @@ -361,7 +363,7 @@ function Invoke-IcingaCommand() return "> " } - } -Args $ScriptBlock, $PSScriptRoot, $IcingaFrameworkData.PrivateData.Version; + } -Args $ScriptBlock, $PSScriptRoot, $IcingaFrameworkData.PrivateData.Version, $ArgumentList; } function Start-IcingaShellAsUser()