xSmbShare PowerShell Module (DSC Resource Kit)

The xSmbShare module is a part of the Windows PowerShell Desired State Configuration (DSC) Resource Kit, which is a collection of DSC Resources produced by the PowerShell Team. This module contains the xSmbShare resource.

 
 
 
 
 
(0)
2,415 times
Add to favorites
Storage
8/7/2015
E-mail Twitter del.icio.us Digg Facebook
  • xSmbShare ChangeAccess parameter gives errors
    1 Posts | Last post June 10, 2016
    • When i try to set changeAccess to 'Everyone' or any group i get following error:
      
      The parameter is incorrect. 
          + CategoryInfo          : InvalidArgument: (MSFT_SMBShare:) [], CimException
          + FullyQualifiedErrorId : Windows System Error 87,New-SmbShare
          + PSComputerName        : localhost
       
      VERBOSE: [KVAD]: LCM:  [ End    Set      ]  [[xSmbShare]MySMBShare]  in 0.0470 seconds.
      The PowerShell DSC resource '[xSmbShare]MySMBShare' with SourceInfo 'C:\Users\kenneth\Documents\shareconfig.ps1::9::7::xSmbShare' threw one or more non-terminating errors while running the Set-TargetResource functionality. 
      These errors are logged to the ETW channel called Microsoft-Windows-DSC/Operational. Refer to this channel for more details.
          + CategoryInfo          : InvalidOperation: (:) [], CimException
          + FullyQualifiedErrorId : NonTerminatingErrorFromProvider
          + PSComputerName        : localhost
       
      VERBOSE: [KVAD]: LCM:  [ End    Set      ]
      The SendConfigurationApply function did not succeed.
          + CategoryInfo          : NotSpecified: (root/Microsoft/...gurationManager:String) [], CimException
          + FullyQualifiedErrorId : MI RESULT 1
          + PSComputerName        : localhost
      
      Im not sure whats going wrong but i ended up using  the FullAccess parameter set to 'Everyone' or a group
  • xSmbShare Test-Dscconfiguration always coming back with false .
    1 Posts | Last post March 15, 2015
    • VERBOSE: [SERVER1]: LCM:  [ Start  Test     ]  [[xSmbShare]Hello]  
      VERBOSE: [SERVER1]: LCM:  [ End    Test     ]  [[xSmbShare]Hello]  in 0.0150 seconds.
      VERBOSE: [SERVER1]: LCM:  [ End    Resource ]  [[xSmbShare]Hello]  
      VERBOSE: [SERVER1]: LCM:  [ End    Test     ]     Completed processing test operation. The ope
      ration returned False.
      VERBOSE: [SERVER1]: LCM:  [ End    Test     ]    in  0.2276 seconds.
      False
      
      I can confirm  that the folder and permissions are set but Test is coming back with false .
      
      Is there any issue with that version ? 
      
  • Test is always false
    4 Posts | Last post December 16, 2014
    • The xSmbShare resource always tests false on our staging server, so the share is re-created every time and configuration drift is always reported.
      
      VERBOSE: [STGWEB1]: LCM:  [ Start  Resource ]  [[xSmbShare]XX]
      VERBOSE: [STGWEB1]: LCM:  [ Start  Test     ]  [[xSmbShare]XX]
      VERBOSE: [STGWEB1]: LCM:  [ End    Test     ]  [[xSmbShare]XX]  in 0.0160 seconds.
      VERBOSE: [STGWEB1]: LCM:  [ Start  Set      ]  [[xSmbShare]XX]
      VERBOSE: [STGWEB1]:                            [[xSmbShare]XX] Share with name XX exists
      VERBOSE: [STGWEB1]:                            [[xSmbShare]XX] Setting FullAccess for Everyone
      VERBOSE: [STGWEB1]: LCM:  [ End    Set      ]  [[xSmbShare]XX]  in 0.1870 seconds.
      VERBOSE: [STGWEB1]: LCM:  [ End    Resource ]  [[xSmbShare]XX]
    • Can you please share your configuration so I can investigate this issue?
      
      Indhu Sivaramakrishnan
      Software Engineer
      PowerShell Team
    • There's nothing configuration-specific to investigate - this appears to be "by design" in the current version of the module (excerpt from function Test-TargetResource):
      
      if ($Ensure -eq "Present")
      {
          if ($share -eq $null)
          {
              $testResult = $false
          }
          elseif ($share -ne $null -and $PSBoundParameters.Count -gt 3)
          # This means some other parameter in addition to Name, Path, Ensure could have been specified
          # Which means we need to modify something
          {
              $testResult = $false
          }
          else
          {
              $testResult = $true
          }
      }
      
      Rather than verifying the current configuration, this test assumes $false if parameters other than Name, Path, or Ensure are provided.
    • I think you are right. In Version 1.0 of this resource, it does a very basic validation of the properties. Ideally, it should be going through all of the properties specified and validate for each of those. I will file a bug for this issue which should be fixed in the next version of this resource.
  • Read only share
    3 Posts | Last post July 15, 2014
    • I am trying to create a share, and set it read-only for everyone.
      In my model it is a software distribution point that I am setting up and copying items to it.
    • Brian, I believe this is what you are looking for. P.S\> requires PSv3.0 +
      
      #Creates a smbshare with access required.
      New-SmbShare -Name "DSC CONFIG" -FolderEnumerationMode AccessBased -FullAccess "Contoso\Administrator" -ReadAccess Everyone `
                           -Description "Desired State Configuration" `
                           -Path "$env:USERPROFILE\Desktop\PowerShell\DSC" -Verbose #-WhatIf
                           
      #Modifies an existing SMBShare
      Grant-SmbShareAccess -Name "DSC CONFIG" -AccountName "Everyone" -AccessRight Read -Verbose #-WhatIf
    • On another note, "NT AUTHORITY\SYSTEM" is what needs read access in order to copy a folder via DSC."
      
      Configuration Get_Folder_Contents {
          param ($Computername)
              Node $Computername
                  {
                   file "Get_Folder_Contents"
                      {
                       Ensure          = "Present"
                       type            = "Directory"
                       SourcePath      = "$MOF_Scripts" #copy this folder
                       MatchSource     = $True
                       Recurse         = $True
                       DestinationPath = "$PowerShell_Folder" # paste folder here
                      }
                  }
      }
  • Can't get it to work
    3 Posts | Last post February 27, 2014
    • I must be missing something fundamental here...
      
      I've copied the files to Program File\WindowsPowerShell\Modules
      
      It shows up when I Get-DscResource:
      
      Name: xComputer Module: MSFT_xComputer
      
      But I just can't get it to load.
      
      Can you give a working example showing exactly what the Modules dir looks like and exactly the form for Import-DscResource is?
    • Sorry, wrong resource in my example, but I suspect once I get any of them to work I'll be golden.
    • Hey Brendan,
      
      Your folder structure should include the following something like this:
      
      PS C:\Program Files\WindowsPowerShell\Modules> tree /f
      
      └───xSmbShare
         │   xSmbShare.psd1
         │
         └───DscResources
             └───MSFT_xSmbShare
                     MSFT_xSmbShare.psm1
                     MSFT_xSmbShare.schema.mof
      
      To use the MSFT_xSmbShare resource in a configuration, you should use “Import-DSCResource –Module xSmbShare” OR “Import-DSCResource –Name MSFT_xSmbShare.”  Based on what you wrote above, it looks like you might have mixed up the resource name (e.g. MSFT_xSmbShare) and the module name (e.g. xSmbShare).  A module can contain many resources (see the xHyper-V module as an example), so you can use “Import-DSCResource –Module <ModuleName>” to import all of the DSC Resources in a single module.
      
      Here’s an example:
      
      Configuration ChangeDescriptionAndPermissionsConfig 
      { 
         Import-DscResource -Name MSFT_xSmbShare 
         # A Configuration block can have zero or more Node blocks 
         Node localhost 
         { 
              # Next, specify one or more resource blocks 
       
            xSmbShare MySMBShare 
            { 
                Ensure = "Present"  
                Name   = "SMBShare1" 
                Path = "C:\Users\Duser1\Desktop"   
                ReadAccess = "User1" 
                NoAccess = @("User3", "User4") 
                Description = "This is an updated description for this share" 
            } 
         } 
      }  
       
      ChangeDescriptionAndPermissionsConfig
      
      Did that help?
      
      John Slack
      Program Manager
      PowerShell Team