Help with Swedish Group Names in Windows Powershell

September 15, 2025 5 answers
Asked by TechTinkerer99
I'm encountering issues with a group name that's based on the system language in Windows. Specifically, it seems like the character "ä" in the group name isn't being recognized correctly, which leads me to think it might be a formatting problem. I'm working with a file that is saved in UTF-8 format, and the PowerShell script I'm using includes a switch statement that assigns group names based on the operating system's language. Here's the code I'm using: ```powershell $systemLanguage = (Get-WmiObject -Class Win32_OperatingSystem).OSLanguage switch ($systemLanguage) { 1033 { $groupName = "Network Configuration Operators" } 1053 { $groupName = "Ansvariga för nätverkskonfigurering" } default { $groupName = "Network Configuration Operators" } } try { $addResult = net localgroup "`"$groupName`"" "`"$formattedUser`"" /add } catch { Write-Host "Error adding user to group: $($_.Exception.Message)" } ``` What can I do to resolve this issue?

Answers

SIDMaster
That group is referenced by the well-known SID S-1-5-32-556, which is culture independent. You can use this in your script like this: `Get-LocalGroup -sid S-1-5-32-556`, and just use the SID to add group members instead of the display name.
Reply to this answer
ByteBard
Using the well-known SID is a great approach! It can eliminate issues related to localization completely. Just ensure you're using the correct SID, and you should be set!
Reply to this answer
PowerShellPro
Just a heads-up, `Get-WmiObject` is considered legacy now, so you might want to switch to `Get-CIMInstance`. Also, instead of using localized names, consider using the well-known SID for the group; it's consistent and avoids language issues. Also, you might want to use `Get-LocalGroup` instead of `net localgroup` for better compatibility.

TechTinkerer99: Thanks a lot for the heads up and advice! I’ll definitely explore using SIDs moving forward! :)

Reply to this answer
ScriptSage
These groups have a well-known SID, which allows you to identify them by SID rather than worrying about localized names. You could try using S-1-5-32-556 for your group. For further details, check the Microsoft documentation!
Reply to this answer
CodeChameleon
Have you tried saving your file with UTF-8 BOM? It usually helps with characters like ä, ø, å for me!

TechTinkerer99: Like magic, thanks a lot! :)

Reply to this answer

Add your answer

Answers are reviewed before publication.

Related Discussions