dsccommunity / xsmbshare Goto Github PK
View Code? Open in Web Editor NEWTHIS MODULE HAS BEEN DEPRECATED Please use ComputerManagementDsc/SmbShare instead: https://github.com/PowerShell/ComputerManagementDsc
License: MIT License
THIS MODULE HAS BEEN DEPRECATED Please use ComputerManagementDsc/SmbShare instead: https://github.com/PowerShell/ComputerManagementDsc
License: MIT License
Hi
I have created a share with xSmbShare and in NOAcces had "users"
Recently wanted to change Noaccess to "" and move "users" to ReadAccess, and allthough the Verbose runs says that the Set script i running, the share maintanes Noaccess for users, and completly ignores the newly added Read access
Seems like the script is trying to modify access, but it doesn't take effect.
PSVersion 5.1
xSmbShare 2.0.0
Server 2012 R2
We used to use this resource without any problems, and suddenly it has started failing across all of our Windows 2012R2 Servers. Here is the output:
PS C:\Windows\system32> $PSVersionTable.PSVersion
Major Minor Build Revision
5 0 10586 117
PS C:\Windows\system32> get-dscresource xSmbShare
ImplementedAs Name ModuleName Version Properties
PowerShell xSmbShare xSmbShare 2.0.0.0 {Name, Path, ChangeAccess, ConcurrentUserLimit...}
PowerShell xSmbShare xSmbShare 1.1.0.0 {Name, Path, ChangeAccess, ConcurrentUserLimit...}
PS C:\Windows\system32> Invoke-DscResource -Method test -Name xSmbShare -Property @{Name='apps$';Description='apps folder share';Ensure='Present';Path='E:';FolderEnumerationMode='AccessBased';FullAccess=@('Everyone')} -Verbose -ModuleName xSmbShare
Invoke-DscResource : Resource xSmbShare was not found.
At line:1 char:1
- CategoryInfo : NotSpecified: (:) [Invoke-DscResource], ArgumentException
- FullyQualifiedErrorId : System.ArgumentException,Microsoft.PowerShell.DesiredStateConfiguration.Commands.InvokeDscResourceMethodCommand
I am using xSMBSHARE via dsc resource in chef recipe and able to enable share for local users but not able to share folder for any AD user/computer.
Below code i am trying :
Chef Recipe :
dsc_resource 'enable_file_share' do
resource :xSmbShare
property :name, 'QUORUM'
property :Path, 'D:\QUORUM'
property :FullAccess, ['domain_name\domain_Computer']
property :Description, "description goes here for this share"
property :PsDscRunAsCredential, ps_credential('domain_name\domain_user', 'XXXX')
end
After i ran chef recipe on Target Server, got the below error:
Running handlers:
[2017-11-07T10:05:08+00:00] ERROR: Running exception handlers
Running handlers complete
[2017-11-07T10:05:08+00:00] ERROR: Exception handlers complete
Chef Client failed. 0 resources updated in 12 seconds
[2017-11-07T10:05:08+00:00] FATAL: Stacktrace dumped to c:/chef/cache/chef-stacktrace.out
[2017-11-07T10:05:08+00:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
[2017-11-07T10:05:08+00:00] FATAL: Chef::Exceptions::PowershellCmdletException: dsc_resource[enable_file_share] (dsc_coo
kbook::enable_file_share line 12) had an error: Chef::Exceptions::PowershellCmdletException: Powershell Cmdlet failed: N
o mapping between account names and security IDs was done.
+ CategoryInfo : NotSpecified: (MSFT_SMBShare:) [], CimException
+ FullyQualifiedErrorId : Windows System Error 1332,New-SmbShare
+ PSComputerName : localhost
The PowerShell DSC resource '[xSmbShare]DirectResourceAccess' with SourceInfo '' 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: (root/Microsoft/...gurationManager:String) [], CimException
+ FullyQualifiedErrorId : NonTerminatingErrorFromProvider
+ PSComputerName : localhost
Please Help!
Unit and integration tests are missing.
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]
There's nothing configuration-specific to investigate (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.
When creating a share, currently it throws an error if an empty string is passed to ANY of the following permissions parameters; FullAccess, ChangeAccess, ReadAccess, NoAccess
Cannot validate argument on parameter 'FullAccess'. The argument is null or empty. Provide an argument that is not null or empty, and then try the command again.
+ CategoryInfo : InvalidData: (:) [], CimException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,New-SmbShare
+ PSComputerName : EDWDEV3-RPT
It would be much better if the error was only thrown if ALL permission parameters were unspecified.
This would make it much easier to pass a hashtable to set a lot of shares at the same time.
Not every type of permission would need to be specified for every share. Currently it is a challenge to dynamically drop parameters if the value you are passing is empty.
Example
foreach($Share in $Node.Shares) {
$ShareName = 'ShareFolder' + $Share.Name
xSmbShare $ShareName
{
DependsOn = $FolderDependsOn
Ensure = 'Present'
Name = $Share.Name
Path = $Share.Path
FullAccess = $Share.FullAccess
ChangeAccess = $Share.ChangeAccess
ReadAccess = $Share.ReadAccess
NoAccess = $Share.DenyAccess'
}
}
Permitting a PSD1 to contain the values
Shares = @(
@{
Name = 'ARCHIVE'
Path = 'E:\ARCHIVE'
FullAccess = 'EDW_Admins'
ChangeAccess = 'AZ\60061671'
ReadAccess = 'Everyone'
},
@{
Name = 'DROPSERVER'
Path = 'E:\DROP'
FullAccess = 'EDW_Supply'
ChangeAccess = @('EDW_Ops', 'EDW_Admins')
ReadAccess = ''
},
@{
Name = 'FTPDROP'
Path = 'E:\FTPDROP'
FullAccess = ''
ChangeAccess = 'Everyone'
ReadAccess = ''
}
)
I've started exploring Powershell DSC and I'm now starting to run into limitations with several of the pack-in and external Resources.
This Resource (xSmbShare) does not appear to work in platforms where Get-SmbShare and its kin are not present, it also does not fail gracefully, instead attempting to continue on despite the inability to do so. One such platform is Windows Server 2008R2
Unfortunately our farm requires us to support Windows Server 2008 R2 for the near future (2012 R2 is on the board for our next Technology Platform).
While not as pretty as Get-SmbShare and its kin, the Resource could be refactored to support the older "NET" wrapper which would give you capability within all Windows Server Platforms Powershell DSC currently targets, this would be my route should I hear nothing back.
I'd assume I could probably work around this by doing some remapping of Get-SmbShare and its kin in the Powershell Environment that is in use (obviously being careful to mimic the existing API), anyone attempting to use this Resource in a Linux environment would probably have to travel the same road...
If the ShareExists and the Path is not consistent with the desired state, the resource does not update the path
By default, clustered file server shares are created with continuous availability turned on. This is not ideal for information worker workloads.
Adding a parameter to disable continuous availability would be helpful.
Unless you set all parameters this resource will execute every time.
This is due to the way the test for change is done. It will compare missing parameters (null) to a set paramter on the system and try and enact the change.
Hello,
I see a lot of examples where you have to crate one or two shares.
How would you do I you had to cretaed hundreds of shares ?
regards
Thierry
Please could you kindly add the ability to disable / enable offline mode for shares.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.