Problem showing Danish special characters (ÆØÅ) in the dashboard

Product: PowerShell Universal
Version: 3.7.9
OS: Windows Server 2022
Webserver: IIS
Git sync: Enabled

We have a problem with dashboards where we cant show æøå, they’ll just show up as æøå, except for the navigation where æøå funny enough actually works :confused:
Looks like a encoding problem, but I’m not sure where the problem is or where to fix it. The entire code is written directly in the code editor in powershell universal.

The site is made as a dashboard with multiple pages, the dashboard code is:

    New-UDListItem -Label "Home" -Icon (New-UDIcon -Icon Home) -OnClick {Invoke-UDRedirect -Url '/home'}
    New-UDListItem -Label "AD" -Icon (New-UDIcon -Icon user) -Children {
        New-UDListItem -Label "AD - æøåSearch" -Icon (New-UDIcon -Icon 'Search') -OnClick {Invoke-UDRedirect -Url '/AD-Search'}
        New-UDListItem -Label "AD - Bruger Oprettelse" -Icon (New-UDIcon -Icon 'UserPlus') -OnClick {}
        New-UDListItem -Label "AD - Opret BrugerProfil" -OnClick {}
        New-UDListItem -Label "AD - User Actions" -Icon (New-UDIcon -Icon 'UserGear') -OnClick {}
        New-UDListItem -Label "AD - Create User with 365 Mailbox" -OnClick {}
        New-UDListItem -Label "AD - AccountStatus" -OnClick {}
        New-UDListItem -Label "AD - Computer" -OnClick {}
        New-UDListItem -Label "AD - NOX " -OnClick {}
    }
    New-UDListItem -Label "Printers" -Icon (New-UDIcon -Icon print) -OnClick {}
    New-UDListItem -Label "BitLocker - Recovery Password" -Icon (New-UDIcon -Icon vault) -OnClick {}
    New-UDListItem -Label "StraksBox" -Icon (New-UDIcon -Icon lightbulb) -OnClick {}
    New-UDListItem -Label "Send" -Icon (New-UDIcon -Icon 'MailBulk') -Children {
        New-UDListItem -Label "Send Ubivox Test mail" -Icon (New-UDIcon -Icon 'Envelope') -OnClick {}
        New-UDListItem -Label "Send SMS" -Icon (New-UDIcon -Icon 'Sms') -OnClick {}
        New-UDListItem -Label "Send SMS (IT-Only)" -Icon (New-UDIcon -Icon 'Sms') -OnClick {}
    }
)

$Pages = @()
$Pages += Get-UDPage -Name 'Home'
$Pages += Get-UDPage -Name 'AD - Search'

New-UDDashboard -Title 'Tools' -Pages $Pages -Navigation $Navigation

And the page shown on the image above is coded like this:


# Use Get-UDPage -Name 'AD - Search' to use this page in your dashboard

# Layout for entire page
$Layout = '{"lg":[{"w":9,"h":13,"x":2,"y":1,"i":"grid-element-LockedUsers","moved":false,"static":false},{"w":1,"h":1,"x":2,"y":0,"i":"grid-element-date","moved":false,"static":false},{"w":9,"h":3,"x":2,"y":14,"i":"grid-element-Search","moved":false,"static":false},{"w":1,"h":22,"x":11,"y":0,"i":"grid-element-help","moved":false,"static":false}]}'

# Show all locked users
$LockedUsers = Search-ADAccount -LockedOut | Get-ADUser -Properties accountlockouttime | ?{$_.DistinguishedName -notlike "*CN=Users"} | sort accountlockouttime -Descending | select AccountLockoutTime, SamAccountName, DistinguishedName
$LockedUsers | %{$_.AccountLockoutTime = $_.AccountLockoutTime -f ("dd-MM-yyyy HH") }
New-UDGridLayout -Content {
    New-UDTable -Id "LockedUsers" -ShowPagination -PageSize 10 -PageSizeOptions @(10, 10) -DisablePageSizeAll -Columns @(
        New-UDTableColumn -Property 'AccountLockoutTime' -Title 'æøåLockedOut Date' -Width 180 -Truncate
        New-UDTableColumn -Property 'action' -Title 'æøåAction' -Width 130 -Truncate -Render {
            New-UDButton -Id "btn$($EventData.SamAccountName)" -Variant 'contained' -Text "Unlock User" -Style @{ Width = "109px"; Height = "15px"; "background-color" = "#4CAF50"; "border-radius" = "4px" } -OnClick { Show-UDToast -Message $EventData.SamAccountName }
        }
        New-UDTableColumn -Property 'SamAccountName' -Title 'UserID' -Width 130 -Truncate -IncludeInSearch
        New-UDTableColumn -Property 'from' -Title 'Locked from' -Width 130 -Truncate
        New-UDTableColumn -Property 'DistinguishedName' -Title 'OU'
    ) -Data $LockedUsers -Dense -ShowSearch
    New-UDDynamic -Id 'date' -Content {
        New-UDTypography -Text "$(Get-Date)" -Id "LockedUsers" -Variant h6
    } -AutoRefresh -AutoRefreshInterval 1

    # User search form
    New-UDStack -Id "Search" -Content {
        New-UDTextbox -Label 'æøåUser search' -Icon (New-UDIcon -Icon 'User') -Placeholder 'æøåBruger, Navn, Afdeling eller Nummer' -Id "SearchBox" -OnEnter {
            Sync-UDElement -Id 'table'
        }
        New-UDButton -Variant 'contained' -Id 'submit' -Text 'Search' -Icon (New-UDIcon -Icon 'Search') -Style @{ Width = "90px"; Height = "15px"; "background-color" = "#4CAF50"; "border-radius" = "4px" } -OnClick {
            Sync-UDElement -Id 'table'
        } -ShowLoading
        New-UDDynamic -Id 'table' -Content {
            $Value = (Get-UDElement -Id 'SearchBox').value
            if ($Value.Length -lt 1) {
                Show-UDToast -Message "You need to search for something"
            } else {
                $searchuser = Get-ADUser -Filter * -Properties Mobile, ipPhone, Department, departmentNumber } | select Name, SamAccountName, Mobile, ipPhone, Department, DistinguishedName
                New-UDTable -Data $searchuser -Dense
            }
        } -LoadingComponent {
            "Loading"
        }
    } -Spacing 2 -Direction 'column'
} -Layout $Layout
New-UDFloatingActionButton -Icon (New-UDIcon -Icon 'question') -OnClick {
    Show-UDModal -Content {
        New-UDTypography -Variant h2 -Text "æøåHelp text"
        New-UDElement -Tag 'p' -Content {}
        New-UDTypography -Text "On this page you can unlock users, this only takes one click."
        New-UDElement -Tag 'p' -Content {}
        New-UDTypography -Text "I søgefeltet nedenfor, kan du fremsøge en bruger. Derefter kan du låse brugeren eller offboarde brugeren, du kan også sende en sms til brugeren."
    } -FullWidth -MaxWidth 'md'
}

Tænker at du skal ha fundet en praktikant til at oversætte det hele til engelsk!

I’ve run into encoding issues when using Windows Powershell.
Are your dashboard using that as an environment by any chance?

Alternatively, try opening the dashboard files manually, then saving them as “UTF8 with BOM”

What encoding does PSU use? UTF-8? - PowerShell Universal - Ironman Software Forums

Edit, coincidentally had a guy complain about this today, opening the script file manuelly in VSCode and saving it as UTF8 with BOM did not solve it for us.

Might still work in your case, our issue was with posting data via REST to servicenow, which required the -ContentType “application/json;charset=utf-8” parameter.

1 Like

We are going to expose the dashboard to people who doesn’t speak English, so having an intern translate the text isn’t a solution.

The environment was Windows Powershell, but changing that didn’t help.
I’ve also tried opening the file on the OS and save it as UTF8 with BOM, which didn’t help either.

Thanks for the suggestions, but no win.

My dashboards has no issue displaying ÆØÅ currently. But I have had issues with it previously in older versions where the solution were to change the encoding of the files. to bad that didn’t help you.

I tried a bunch of stuff just now to get ÆØÅ to not work, chancing environment, tried lots of encoding types, without any luck. :sweat_smile:

I’m not near a dashboard right now, but some encoding settings is stored in $PSDefaultParameterValues If anything looks off in that, they can be changed with something like $PSDefaultParameterValues['*:Encoding'] = 'utf8

utf 8 - Changing PowerShell’s default output encoding to UTF-8 - Stack Overflow

1 Like

I’m experiencing the same result. I thought maybe it had to do with the table or something but all those chars are showing up in PS7 and WinPS for me.

1 Like

Still not sure what the problem was, but I removed the file from the OS file manager, created a new file in notepad++ (explicit selected UTF8 BOM) rewrote the script and now it’s working.

Thanks for all the suggestions, it helped me pinpoint the problem.
And @PorreKaj was apparently right that it was a problem with the encoding of the file, just still wonder why it didn’t help just to resave it with new encoding.

Anyways problem solved, thanks everybody :smiley:

1 Like

Hmm but when I edit the page from the powershell universal interface, it changes back to not showing æøå.

It doesn’t happen in the dashboard itself, but only in pages i make in dashboards, hope that makes sense (Added picture shows what kind of pages I’m talking about).
image

1 Like

Ah ha! While I haven’t reproduced this myself, I do see that in other configuration files we are writing out the UTF8 preamble but not with dashboard pages. I’ll get a fix in for this.

2 Likes