xSmbShare resource on Windows Server 2008 R2

The xSmbShare resource included in the DSC Resource Kit doesn’t appear to be supported in Windows Server 2008 R2 as it uses the SmbShare module which comes with WS 2012, and now WS 2008 R2. Can someone confirm that I am correct about this?

If I am correct, as I need to be able to create shares on WS2008 R2, any suggestions on how to go about building a custom DSC resource for this?

The smbshare module uses CDXML - cmdlets over objects technology - in this case WMI classes. These classes are only available on Windows 8/2012 and later.

You can create shares with the Win32_Share class that is available on Windows 2008 R2. The easiest way may to create a script to do the work and call that from DSC

I came across the following: http://get-carbon.org/help/Install-SmbShare.html. While there isn’t a way to see if the share exists, it does provide a mechanism to create one.

The “Carbon” module (http://get-carbon.org/) looks to have a lot of stuff that could be useful in building custom DSC resources for WS 2008 R2, which has much less to offer than WS 2012.

Does anyone have any experience with the “Carbon” module? Is it worth taking a look at? Should I stay away?

I’m struggling with the same thing. I need to create a share on a Windows 7 machine, so xSmbShare will not work for me. You can use the “net share” command to do this, but I can’t figure out how to make the command idempotent.

This works great the first time I run it, but it fails the second time (because the share already exists so net share returns an error code).

WindowsProcess CreateTestShare
Path = “C:\windows\System32\net.exe”
Arguments = “share TestShare=c:\testshare /GRANT:username,FULL”
Ensure = “Present”