none
SMB Strange Error RRS feed

  • Question

  • Hello TechNet.

    During my Server task sequence, I call one of my scripts that sets up a couple of shares using New-SMBShare cmdlet.Just recently I have started getting the following error for, strangely, no reason whatsoever.

    * Cannot find the Windows Powershell Datafile 'SmbLocalisation.psd1' in directory 'C:\Windows\system32\WindowsPowershell\v1.0\Modules\Smbshare\en\' or in any parent culture directories

    *At C:\Windows\system32\WindowsPowerShell\v1.0\Modules\SmbShare\SmbScriptModule.psm1:15 char1+ Import-LocalizedData -BindingVariable_system_translation -Filename SmbLocalisation...

    *File Not Found

    Now I have checked the location of SmbLocalization.psd1 and the path called is wrong. 

    It is not C:\windows\system32\WindowsPowerShell\v1.0\Modules\SmbShare\en\
    but rather C:\windows\system32\WindowsPowerShell\v1.0\Modules\SmbShare\en-US\

    This worked fine until a recent batch of updates ran on the deployment server and I am unsure how to set the correct location during the script.

    I use Import-Module SMSShare although I suppose I could take advantage of auto module loading and leave that out and just call New-Smbshare when needed.  Any ideas for me?


    MCP, MCTS, MCITP, MCSA.. Gunning for MCSE Cloud | Please visit www.deploymentshare.com | If I help you solve your issue please mark my reply as the answer.




    Thursday, January 15, 2015 2:51 PM

Answers

  • OK so tried that, it output en-US. 

    Very strange.

    Since I'd had this running without issues beforehand, and I had deployed an image to the same VM over and over I decided to delete and re-create the VM, then deploy a second time.

    SUCCESS!

    I haven't a clue why it was throwing this strange error, especially since I had made no script changes.  However a fresh VM solved the issue.

    Keith, thanks for your assistance.


    MCP, MCTS, MCITP, MCSA.. Gunning for MCSE Cloud | Please visit www.deploymentshare.com| I invite you to follow me on Twitter:@deploymentshare | If I help you solve your issue please mark my reply as the answer.

    Saturday, January 17, 2015 1:10 PM

All replies

  • Just ran Import-Module SMBShare on my local test machine with no problems.

    Reading SMBScriptModule.psm1 shows the following command on line 15:

    Import-LocalizedData -BindingVariable _system_translations -fileName SmbLocalization.psd1

    Getting Help on Import-LocalizedData shows:

    Import-LocalizedData begins the search in the directory where the script file is located (or the value

    of the BaseDirectory parameter). It then searches within the base directory for a subdirectory with the

    same name as the value of the $PsUICulture variable (or the value of the UICulture parameter), such as

    "de-DE" or "ar-SA". Then, it searches in that subdirectory for a .psd1 file with the same name as the

    script (or the value of the FileName parameter).


    I would be curious to know what $PSUICulture variable is set to when running the MDT Script.


    Keith Garner - Principal Consultant [owner] - http://DeploymentLive.com


    Friday, January 16, 2015 8:07 PM
    Moderator
  • Thanks for taking the time to reply.

    Running Get-UICulture I get a reply of en-US.

    Here is the script that runs:

    Function Create-Shares
      {
       Import-Module SmbShare
       
        function SetPerms ([string]$Path, [string]$ADgroup, [string]$Permission) 
            {
                $acl = Get-Acl $Path
     	        $accessRule = New-Object System.Security.AccessControl.FileSystemAccessRule $ADGroup, $Permission, "ContainerInherit,ObjectInherit","None","Allow"
     	        $acl.SetAccessRule($accessRule)
     	        $acl | Set-Acl $Path
            } 
    
        $shareArray = @("SHARE1$", "SHARE2$")
    
        $shareArray | ForEach-Object{
    	$sharePath = "C:\"+$_
    	New-Item $sharePath -ItemType directory
    	
    	Switch ($_){
            ("SHARE1$"){
                New-SmbShare -Name $_ -Path $sharePath -FullAccess Everyone
    			SetPerms -path $sharePath -ADGroup "Authenticated Users" -Permission "Modify"
            }
    		("SHARE2$"){
                New-SmbShare -Name $_ -Path $sharePath -FullAccess Everyone
    			SetPerms -path $sharePath -ADGroup "Authenticated Users" -Permission "Modify"
            }
    	                } 
        }
      }
    Create-Shares

    Pretty straight forward stuff right? script has run a thousand times without errors.  Rather annoying this started appearing recently without me changing, puzzler.


    MCP, MCTS, MCITP, MCSA.. Gunning for MCSE Cloud | Please visit www.deploymentshare.com| I invite you to follow me on Twitter:@deploymentshare | If I help you solve your issue please mark my reply as the answer.

    Friday, January 16, 2015 10:24 PM
  • Change to:
    Function Create-Shares
      {
       Write-Host "UI Culture: $PSUICulture"
       Import-Module SmbShare
    ...
    
    And see what it says in bdd.log

    Keith Garner - Principal Consultant [owner] - http://DeploymentLive.com

    Friday, January 16, 2015 10:27 PM
    Moderator
  • OK so tried that, it output en-US. 

    Very strange.

    Since I'd had this running without issues beforehand, and I had deployed an image to the same VM over and over I decided to delete and re-create the VM, then deploy a second time.

    SUCCESS!

    I haven't a clue why it was throwing this strange error, especially since I had made no script changes.  However a fresh VM solved the issue.

    Keith, thanks for your assistance.


    MCP, MCTS, MCITP, MCSA.. Gunning for MCSE Cloud | Please visit www.deploymentshare.com| I invite you to follow me on Twitter:@deploymentshare | If I help you solve your issue please mark my reply as the answer.

    Saturday, January 17, 2015 1:10 PM
  • I found a workaround if you are invoking the command remotely:

    $usSession = New-PSSessionOption -Culture en-US -UICulture en-US 
    Invoke-Command -ComputerName $serverName -SessionOption $usSession -ScriptBlock ` 

    # Should be in en-US culture 
    Get-Culture

    # Should work now 
    Import-Module SMBShare

    # Test... 
    Get-SmbShare 
    }

    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.

    This has been up at the MS UserVoice feedback site for a while: https://windowsserver.uservoice.com/forums/301869-powershell/suggestions/11351979-smbshare-module-localization-does-not-work-when-ui


    Key Artefacts

    Monday, February 13, 2017 8:24 AM