New-SMBShare on non English system

Viewed 71

When i try to create share using PowerShell on a Spanish system with following command:

New-SMBShare -Name 'scripts$' -Path 'c:\scripts' -ChangeAccess Everyone

I get an error which translates into:

New-SMBShare: No mapping was made between account names and security identifiers.

Because it expects Todos group instead of Everyone.

Is there a way to have one New-SmbShare command for all localizations?

1 Answers

The Everyone identity is known as a "Well-known" Security Identifier.

You can construct and translate it to the localized representation like this:

$EveryoneWKSID = [System.Security.Principal.SecurityIdentifier]::new([System.Security.Principal.WellKnownSidType]::WorldSid, $null)
$EveryoneLocal = $EveryoneWKSID.Translate([System.Security.Principal.NTAccount]).Value

At which point you can do:

New-SMBShare -Name 'scripts$' -Path 'c:\scripts' -ChangeAccess $EveryoneLocal
Related