SmbShare module localization does not work when UICulture is not en-US
I am attempting to use invoke-command to run a script on a remote computer. The UICulture of my local machine is en-GB. During the execution of the script on the remote computer, it does an "Import-Module SmbShare". This fails with the following error:
Cannot find the Windows PowerShell data file 'SmbLocalization.psd1' in directory 'C:\Windows\system32\WindowsPowerShell\v1.0\Modules\SmbShare\en-GB', or in any parent culture directories.
Looking at the modules folder, I can see that the SmbShare folder does not contain an en-GB folder but does contain an en-US folder with an SmbLocalization.psd1 file inside. However, there is no default SmbLocalization.psd1 file located directly within the SmbShare directory (as I would have expected). This means the command will fail when the UI Culture of the session is set to anything other than en-US.
This behaviour has been confirmed on multiple remote machines (Windows Server 2012 R2 DataCenter) and occurs regardless of which display language is configured on the remote machine.
I suggest copying the SmbShare\en-US\SmbLocalization.psd1 file to the SmbShare directory so that there is a default available for non-US users.
I found a workaround:
$usSession = New-PSSessionOption -Culture en-US -UICulture en-US
Invoke-Command -ComputerName $serverName -SessionOption $usSession -ScriptBlock `
# Should be in en-US culture
# Should work now
I had to run commands on the real server anyway to process local paths. Not sure if you are allowed to set the local culture in the existing session, so invoke might be necessary even if you don't want to execute remotely.
Also for this feature, I suggest an alternate behaviour that the PS error level should not be "error" when localization file is missing. Perhaps we are only experiencing this error because of Set-StrictMode. I also set $ErrorActionPreference to "Stop". If the en-GB localization is not there, we should fallback to en-US without an error level causing us to break.
Same error with en-GB display language (UI culture) in de-DE region (format culture) on a en-US (MUI) Windows 10 OS.