Search code examples
powershellmultilingual

using net user multilanguage language


I am setting up a bunch of computers, and for this i am using powershell.
To setup admin accounts, i have used the net command, but as I get some pc's with danish OS and some with english the commands differ slightly.

Danish version:
net localgroup Administratorer username /add

english version:
net localgroup Administrators username /add

This means i need two versions of the script. is it possible to take another aproach? perhaps using some ID to identify the admin group? like writing 3334 instead of administator


Solution

  • The builtin Administrators group may indeed have different names depending on the installation language, but the group's security identifier is always the same:

    S-1-5-32-544
    

    To find the local name, use WMI:

    $AdminGroupName = (Get-WmiObject -Class Win32_Group -Filter 'LocalAccount = True AND SID = "S-1-5-32-544"').Name
    

    Now you can do:

    net localgroup $AdminGroupName username /add