Umlauts and double quotes in local powershell script

Hi there,
I coded a powershell script for local checks, basically it’s working.
But there are two ugly flaws:

First, I cannot use umlauts in the output message. Does anyone know how to set the output encoding for check_mk?

In the documentation I found, that the service name must be quoted, when white spaces are used. But when adding them, I get Invalid performance data: u’Service’

Write-Output “0 "My Service" Woche=$week $message” ->gives error
using Write-Output “0 My_Service Woche=$week $message” ->works fine

Calling from Powershell it looks correct.

Maybe both issues have the same cause, so I did not split the request.

Thanks in advance

Win 16 server, check_mk 1.6.0p17

Documentation states that local checks can’t have spaces (in the service name field).

Take a look.

Cheers,

For this problem the used Powershell version is important.

Some more information from my systems :slight_smile:
It is working here.


Local check with space and umlauts.
There is only on important thing to do for your Powershell script. It must be saved as UTF8 with BOM.

The shown output is produced with this simple script

[Console]::OutputEncoding = [System.Text.UTF8Encoding]::new($false)
Write-Host('0 "Local Check" - UTF8 Coding Mit Umlauten Ä Ü Ö ä ü ö')

The first line is also important.
Working is this on my systems with Powershell 5.1
Starting with Powershell Core 6 you don’t need to do these things with file saved as. The system then outputs every time UTF-8 without BOM.
On my Powershell 7 systems only the write-host line is needed no extras.

Agent script output without BOM

<<<local:sep(0)>>>
0 "Local Check" - UTF8 Coding Mit Umlauten Ä Ü Ö ä ü ö

Same script with BOM

<<<local:sep(0)>>>
0 "Local Check" - UTF8 Coding Mit Umlauten Ä Ü Ö ä ü ö
2 Likes

That’s it thank you very much :slight_smile:

echo 0 "My 1st service" - This static service is always OK

Taken from the documentation. But maybe it’s not supported in 1.6?

Yes this was added with 2.0

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed. Contact an admin if you think this should be re-opened.