Icinga Powershell Module Offline Mode Install

Hello

:slight_smile: After some push and nudge by @cstein want to explore the powershell module and move away from nsclient. We already have puppet and sccm method to install and configure agent. I do not want to touch those and just install the powershell module alone without installing / reinstalling the agent.

Also we need to install it in offline mode.

[Net.ServicePointManager]::SecurityProtocol = "tls12, tls11";
$ProgressPreference = "SilentlyContinue";
$global:IcingaFrameworkKickstartSource = 'C:\iCinga\icinga-powershell-kickstart.psi';
$Script = (Invoke-WebRequest -UseBasicParsing -Uri $global:IcingaFrameworkKickstartSource).Content;
$Script += "`r`n`r`n Start-IcingaFrameworkWizard;";
Invoke-Command -ScriptBlock ([Scriptblock]::Create($Script));

And boom error error error :slight_smile: Obviously I did I mistake.

Exception calling "Create" with "1" argument(s): "At line:1 char:5
+ 102 117 110 99 116 105 111 110 32 83 116 97 114 116 45 73 99 105 110  ...
+     ~~~
Unexpected token '117' in expression or statement.
At line:1 char:9
+ 102 117 110 99 116 105 111 110 32 83 116 97 114 116 45 73 99 105 110  ...
+         ~~~
Unexpected token '110' in expression or statement.
At line:1 char:13
+ 102 117 110 99 116 105 111 110 32 83 116 97 114 116 45 73 99 105 110  ...
+             ~~
Unexpected token '99' in expression or statement.
At line:1 char:16
+ 102 117 110 99 116 105 111 110 32 83 116 97 114 116 45 73 99 105 110  ...
+                ~~~
Unexpected token '116' in expression or statement.
At line:1 char:20
+ 102 117 110 99 116 105 111 110 32 83 116 97 114 116 45 73 99 105 110  ...
+                    ~~~
Unexpected token '105' in expression or statement.
At line:1 char:24
+ 102 117 110 99 116 105 111 110 32 83 116 97 114 116 45 73 99 105 110  ...
+                        ~~~
Unexpected token '111' in expression or statement.
At line:1 char:28
+ 102 117 110 99 116 105 111 110 32 83 116 97 114 116 45 73 99 105 110  ...
+                            ~~~
Unexpected token '110' in expression or statement.
At line:1 char:32
+ 102 117 110 99 116 105 111 110 32 83 116 97 114 116 45 73 99 105 110  ...
+                                ~~
Unexpected token '32' in expression or statement.
At line:1 char:35
+ 102 117 110 99 116 105 111 110 32 83 116 97 114 116 45 73 99 105 110  ...
+                                   ~~
Unexpected token '83' in expression or statement.
At line:1 char:38
+ 102 117 110 99 116 105 111 110 32 83 116 97 114 116 45 73 99 105 110  ...
+                                      ~~~
Unexpected token '116' in expression or statement.
Not all parse errors were reported.  Correct the reported errors and try again."
At line:1 char:1
+ Invoke-Command -ScriptBlock ([Scriptblock]::Create($Script));
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : ParseException

Hello there!

@cstein is the right person to bug about this actually :slight_smile:

I will ask him to have a look at this later, maybe we can figure it out together :wink:

Have a nice week,
Feu

1 Like

Hello,

the issue here is that local files are read as β€œbinary” content and not text by using Invoke-WebRequest.
To resolve this, either use Get-Content instead of Invoke-WebRequest or convert the byte array to string first:

$global:IcingaFrameworkKickstartSource = 'C:\iCinga\icinga-powershell-kickstart.psi';
$Script = (Invoke-WebRequest -UseBasicParsing -Uri $global:IcingaFrameworkKickstartSource).Content;
$Script = [System.Text.Encoding]::UTF8.GetString($Script);
$Script += "`r`n`r`n Start-IcingaFrameworkWizard;";
Invoke-Command -ScriptBlock ([Scriptblock]::Create($Script));

I hope this helps!

2 Likes