Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compare-Functions doesn't work with Powershell 4 and Framework Version 1.5.2 #300

Closed
stevie-sy opened this issue Jul 15, 2021 · 8 comments · Fixed by #358
Closed

Compare-Functions doesn't work with Powershell 4 and Framework Version 1.5.2 #300

stevie-sy opened this issue Jul 15, 2021 · 8 comments · Fixed by #358
Assignees
Labels
Bug There is an issue present
Milestone

Comments

@stevie-sy
Copy link

I'm testing the Framework Version 1.5.2 and the Plugins 1.5.1 on our systems. While everything is fine on Windows Server 2016 and 2019 with PowerShell 5.1, the new moudle versions doesn't work with PowerShell 4 and Windows Server 2012R2. Version 1.4.x is still working fine.

Here are some error messages:
firewall
image

timesync:
image
image

It look like the triggerd check functions for warn/critical doeing something diffrent in the new version. Every of these functions calls Compare-IcingaPluginThresholds. Is it possible that this one doing something wrong? Or one of the Convert-functions you are calling? Maybe a constructor call which is only possible in PowerShell 5.x? I didn't find anything which could create these error messages.

@LordHepipud
Copy link
Collaborator

Thank you for the issue. The System.Text.StringBuilder should be fixed with v1.5.1, I used the more backwards compatible approach there.

Have you rebuild the Framework Code Cache in case it is enabled, to ensure the update is applied properly? The other issues should have been fixed as well already.

I will have a closer look on these on a 2012 R2 test environment.

@LordHepipud LordHepipud self-assigned this Jul 16, 2021
@LordHepipud LordHepipud added this to the v1.6.0 milestone Jul 16, 2021
@LordHepipud LordHepipud added the Bug There is an issue present label Jul 16, 2021
@stevie-sy
Copy link
Author

Ok, if this is fixed than it's strange. We don't use the code cache - the folder C:\Program Files\WindowsPowerShell\Modules\icinga-powershell-framework\cache is empty.
BTW is there a way to check this in easy way. In the docs I'll only find Cmdlet for Enable/Disable/Write the cache. There is no Get-Cmdlet.

Thanks for checking this

@LordHepipud
Copy link
Collaborator

This is weird. I will try to reproduce this.

For the command:

Get-IcingaFrameworkCodeCache

It will tell you if it is enable or not.

@stevie-sy
Copy link
Author

Thanks for the command. I'll miss this in this docs https://icinga.com/docs/icinga-for-windows/latest/doc/frameworkusage/05-Enable-Framework-Code-Caching/#disable-icinga-framework-code-cache 😉

Also here I am curious what you will find 🚀

@LordHepipud
Copy link
Collaborator

LordHepipud commented Aug 18, 2021

I played a lot around with Icinga for Windows and Windows 2012 R2 as preparation for 1.6.0 - for me it just works fine.
Is it possible that for some reason there are other versions being included into this?

I can't get this to reproduce sadly.

By the way: The code caching is by default embedded with Icinga for Windows 1.6.0 - there is no way around this anymore :D
Therefor the Cmdlets have been removed with 1.6.0

@stevie-sy
Copy link
Author

That sounds sad. I'll take a look again and report back

@stevie-sy
Copy link
Author

A colleague took a look into your code and he gave me following feedback:
With PowerShell 4 it isn't possible to check GpoBoolean against en empty String.
E.g. Line 209 from New-IcingaCheck.psm1:
if ($this.Value -gt $this.Maximum -And ...

e.g. for the firewall-check he suggest following solution:
$FirewallCheck = New-IcingaCheck -Name "Firewall Profile $singleprofile" -Value ($FirewallData.Enabled -eq [Microsoft.PowerShell.Cmdletization.GeneratedTypes.NetSecurity.GpoBoolean]::True) -ObjectExists $FirewallData -Translation @{ 'true' = 'Enabled'; 'false' = 'Disabled'};
instead of
$FirewallCheck = New-IcingaCheck -Name "Firewall Profile $singleprofile" -Value $FirewallData.Enabled -ObjectExists $FirewallData -Translation @{ 'true' = 'Enabled'; 'false' = 'Disabled'};

@LordHepipud
Copy link
Collaborator

Now I see the problem. I assumed you had the issue on every single plugin, but yes - on the Firewall plugin I have the same issue on 2012 R2.

I didn't realize this was the only plugin affected. I will fix this with 1.6.0, which will be released on Tuesday.

Thank you for the input!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug There is an issue present
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants