test-dscconfiguration fails with MSFT_xSmbShare

Hello,

I have written a test configuration to create a local folder, and a share for that folder, on a Windows 2012R2 server.
The configuration gets applied just fine. My question is in regard to “test-dscconfiguration”

When I execute “test-dscconfiguration -verbose” I always get a false return, even though the folder and share are present.
(pre)
VERBOSE: An LCM method call arrived from computer SERVERNAME with user sid S-1-5-21-854245398-1004336348-725345543-165690.
VERBOSE: [PHELDSCDEV001]: LCM: [ Start Test ]
VERBOSE: [PHELDSCDEV001]: LCM: [ Start Resource ] [[File]WebRoot]
VERBOSE: [PHELDSCDEV001]: LCM: [ Start Test ] [[File]WebRoot]
VERBOSE: [PHELDSCDEV001]: [[File]WebRoot] The destination object was found and no action is required.
VERBOSE: [PHELDSCDEV001]: LCM: [ End Test ] [[File]WebRoot] in 0.0000 seconds.
VERBOSE: [PHELDSCDEV001]: LCM: [ End Resource ] [[File]WebRoot]
VERBOSE: [PHELDSCDEV001]: LCM: [ Start Resource ] [[xSmbShare]WebRootShare]
VERBOSE: [PHELDSCDEV001]: LCM: [ Start Test ] [[xSmbShare]WebRootShare]
VERBOSE: [PHELDSCDEV001]: LCM: [ End Test ] [[xSmbShare]WebRootShare] in 0.0160 seconds.
VERBOSE: [PHELDSCDEV001]: LCM: [ End Resource ] [[xSmbShare]WebRootShare]
VERBOSE: [PHELDSCDEV001]: LCM: [ End Test ] Completed processing test operation. The operation returned False.
VERBOSE: [PHELDSCDEV001]: LCM: [ End Test ] in 0.0780 seconds.
False
(/pre)

Here is my configuration, any ideas?
(pre)$configdata = @{

Windows feature “NET-Win-CFAC” not found on WindowsFeature

AllNodes = @(
    @{
        NodeName= @("localhost");
        Environment="lab"
        Role="Web"
    }

)

}

Configuration MyWebServer
{
param(
[string]$Action=“Present”
)

Import-DscResource -Name MSFT_xSmbShare

Node $AllNodes.NodeName
{
    File WebRoot
    {
        Ensure ="$Action"
        DestinationPath="c:\webroot"
        Type="Directory"
    }
    xSmbShare WebRootShare
    {
        Ensure = "$Action"
        Name = "webroot"
        Path = "c:\webroot"
        FullAccess = @("Administrators")
        Description = "Read only share for deployed web site files"
        DependsOn = "[File]WebRoot"
    }
}

}

MyWebServer -ConfigurationData $configdata(/pre)

I decided to read the module code on this one, and found that if you set more than just Name, Path, Ensure, the Test will automatically fail:
(pre)
$share = Get-SmbShare -Name $Name -ErrorAction SilentlyContinue -ErrorVariable ev
if ($Ensure -eq “Present”)
{
if ($share -eq $null)
{
$testResult = $false
}
elseif ($share -ne $null -and (b)$PSBoundParameters.Count -gt 3(/b))
# 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
}
(/pre)

Instead of failing, it should detect which settings are in use, and test each one.

That’s pretty much where the “x” comes from. :slight_smile: These things are not ready for prime time, in some cases, but offer us a good start. There’s a cSmbShare version of this resource on the PowerShell.org GitHub repository. I don’t know, off the top of my head, if this same bug exists there. If it does, though, anyone can fix it and submit a pull request.

Yeah, I looked at the cSmbShare version as well, and the same issue exists there.

OK. If you’d like to fix this yourself, please feel free, and submit a pull request back to the PowerShell.org repo. Otherwise, just submit an Issue report for it on GitHub, and someone else will take care of it at some point.

I have filed an issue for tracking. thanks.