FriendsOfMDT / PSD

PowerShell Deployment
MIT License
471 stars 72 forks source link

Added suggestion for a solution to localized languages #70

Closed baardhermansen closed 1 year ago

baardhermansen commented 1 year ago

After participating in issue #50 regarding localized account names, i was tempted to look into it. This PR is a suggestion that uses English, German and Spanish as examples. Basically, the change utilizes the PowerShell command Import-LocalizedData, which is available from PowerShell 3.0 and onwards.

As you'll notice, the SYSTEM account name remains unchanged. The reason for that is that i did not see any localization of the account name i neither Spanish nor German Server 2016.

I also used VS Code's "Format Document" so the number of additions and deletions makes it look a lot worse than it is!

GeoSimos commented 1 year ago

Hi @baardhermansen,

Thank you for your pull request, it is really appreciated, however it complicates significantly the solution because we will end up with multiple install-psd.ps1 files for each language. As we have stated initially, the solution is based on English US language O/S, the ability to work on localized versions should be handling the localized user accounts/groups, besides that we are working on a newer installer and will cover this functionality and avoid over-engineering it.

baardhermansen commented 1 year ago

Hi @baardhermansen,

Thank you for your pull request, it is really appreciated, however it complicates significantly the solution because we will end up with multiple install-psd.ps1 files for each language.

There will be multiple Install-PSD.psd1 files, each residing in its language folder. That's because of the way Import-LocalizedData works; each language file must have the same name as the calling .ps1 file.

As we have stated initially, the solution is based on English US language O/S, the ability to work on localized versions should be handling the localized user accounts/groups, besides that we are working on a newer installer and will cover this functionality and avoid over-engineering it.

I get that. The suggested solution just made it easy for people to add new languages without touching 'Install-PSD.ps1'. But hey, at least i learnt something new :)

GeoSimos commented 1 year ago

I get that. The suggested solution just made it easy for people to add new languages without touching 'Install-PSD.ps1'. But hey, at least i learnt something new :)

We really appreciate your effort, that's the spirit, to learn new things!

jens-mueller commented 1 year ago

I'am not a good programmer, but i use this solution:

#region Translate Username
$localUsers=@{
    'Users'='S-1-5-32-545'
    'Administrators'='S-1-5-32-544'
    'SYSTEM' = 'S-1-5-18'
    'EVERYONE'='S-1-1-0'
    'CREATOR OWNER'='S-1-3-0'
}
$translatedUsers=@{}
foreach($engUserName in $localUsers.Keys){
    $userSID = $localUsers.$engUserName
    $SID = New-Object System.Security.Principal.SecurityIdentifier($userSID)
    $objUser = $SID.Translate([System.Security.Principal.NTAccount])
    $translatedUsers.Add($engUserName,$objUser.Value)
}
#endregion

and then i use the hashtable in code like this for example :

New-SmbShare -Name $psDeploymentShare -Path $psDeploymentFolder -FullAccess $translatedUsers.Administrators -Description $description
.....
icacls $psDeploymentFolder /grant """$($translatedUsers.Users)"":(OI)(CI)(RX)"| Out-Null
icacls $psDeploymentFolder /grant """$($translatedUsers.Administrators)"":(OI)(CI)(F)"| Out-Null
icacls $psDeploymentFolder /grant """$($translatedUsers.SYSTEM)"":(OI)(CI)(F)"|Out-Null

So it could be one installer-File, maybe that helps

baardhermansen commented 1 year ago

@jens-mueller I really like it, pretty short and easy to implement.