'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 1:[1]
One solution could be to leverage the .NET framework (via Powershell) to retrieve the localized name of the administrators group. I find it better than hardcoding the SID of the administrators group, even though it never changes.
$adminGroupSid = [System.Security.Principal.SecurityIdentifier]::new([System.Security.Principal.WellKnownSidType]::BuiltinAdministratorsSid,$null)
$adminGroupName = $adminGroupSid.Translate([System.Security.Principal.NTAccount]).ToString()
$adminsName = ($adminGroupName -split "\\")[1]
From then on, you can either use $adminsName when calling net localgroup
net localgroup $adminsname /add <user>
Solution 2:[2]
in case you want to run it as a package in SCCM without content folder
%windir%\Sysnative\windowsPowershell\V1.0\powershell -command "$an='AdminUser';$ap='password'; net user /add $an $ap; $agn = (gwmi -Class Win32_Group -Filter 'LocalAccount=True AND SID="""S-1-5-32-544"""').Name;net localgroup $agn $an /add"
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Poorkenny |
| Solution 2 | Stephan |
