Giter Club home page Giter Club logo

xsmbshare's Introduction

THIS MODULE HAS BEEN DEPRECATED

It will no longer be released. Please use the 'SmbShare' resource in ComputerManagementDsc instead.

xSmbShare Resource

Build status

The xSmbShare module contains the xSmbShare DSC resource for setting up and configuring an SMB share.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

Contributing

Please check out common DSC Resources contributing guidelines.

Resources

xSmbShare

  • Name: Name of the SMB share.
  • Path: Path to the share.
  • Description: Description of the share.
  • ChangeAccess: Specifies which user will be granted modify permission to access the share.
  • ConcurrentUserLimit: Specifies the maximum number of concurrently connected users that the new SMB share may accommodate. If this parameter is set to 0, then the number of users is unlimited. The default value is 0.
  • EncryptData: Indicates that the share is encrypted.
  • FolderEnumerationMode: Specifies which files and folders in the new SMB share are visible to users.
  • CachingMode: Specifies the caching mode of the offline files for the SMB share. { 'None' | 'Manual' | 'Programs' | 'Documents' | 'BranchCache' }
  • FullAccess: Specifies which accounts are granted full permission to access the share.
  • NoAccess: Specifies which accounts are denied access to the share.
  • ReadAccess: Specifies which accounts are granted read permission to access the share.
  • Ensure: Specifies if the share should be added or removed.
  • ShareState: State of the share.
  • ShareType: Type of the share.
  • ShadowCopy: Specifies if this share is a ShadowCopy.
  • Special: Specifies if this share is a Special Share. Admin shares, default shares, IPC$ share are examples.

Versions

Unreleased

  • THIS MODULE HAS BEEN DEPRECATED. This resource module will no longer be released. Please use the resource 'SmbShare' in the ComputerManagementDsc module instead.

2.2.0.0

  • Improved Code logic & cosmetic changes
  • Update appveyor.yml to use the default template.
  • Added default template files .codecov.yml, .gitattributes, and .gitignore, and .vscode folder.
  • Changes to xSmbShare

2.1.0.0

  • Corrected typo on ShareState and ShareType descriptions (Specfies -> Specifies)

2.0.0.0

  • Converted appveyor.yml to install Pester from PSGallery instead of from Chocolatey.
  • Added default value of "Present" for the Ensure parameter. (Note: due to how the module's logic is written, this is a breaking change; DSC configs that did not specify a value for Ensure would have behaved as though it were set to Present in the Test-TargetResource function, but to absent in Set-TargetResource, removing the share instead of creating it.)

1.1.0.0

  • Fixed bug in xSmbShare resource which was causing Test-TargetResource to return false negatives when more than three parameters were specified.

1.0.0.0

  • Initial release with the following resources
    • xSmbShare

Examples

Ensure the an SMB share exists

This configuration ensures that there is a share with the description of "This is a test SMB Share".

Configuration ChangeDescriptionConfig
{
    Import-DscResource -Name MSFT_xSmbShare
    # A Configuration block can have zero or more Node blocks
    Node localhost
    {
        xSmbShare MySMBShare
        {
            Ensure = "Present"
            Name   = "SMBShare1"
            Path = "C:\Users\Duser1\Desktop"
            Description = "This is a test SMB Share"
        }
    }
}

ChangeDescriptionConfig

Ensure description and permissions for a share

This configuration ensures that the description and permissions for a share are as specified.

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

Remove an SMB share

This example ensures that the SMB share used in the previous examples does not exist.

Configuration RemoveSmbShareConfig
{
    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 = "Absent"
            Name   = "SMBShare1"
            Path = "C:\Users\Duser1\Desktop"
        }
    }
}

RemoveSmbShareConfig

xsmbshare's People

Contributors

dlwyatt avatar joeyaiello avatar johlju avatar karolkaczmarek avatar kwirkykat avatar mikefrobbins avatar powershellteam avatar travisez13 avatar windos avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

xsmbshare's Issues

Parameters all need defaults

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.

Request - Should be able to pass empty strings to all but one Access Parameter.

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 = ''
	}
)

Permission change doesn't take effect

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

Unable to Add Domain User/Computer

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!

Resource xSmbShare was not found

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

  • Invoke-DscResource -Method test -Name xSmbShare -Property @{Name='app ...
  • - CategoryInfo          : NotSpecified: (:) [Invoke-DscResource], ArgumentException
    - FullyQualifiedErrorId : System.ArgumentException,Microsoft.PowerShell.DesiredStateConfiguration.Commands.InvokeDscResourceMethodCommand
    

What if we have a lot of shares ?

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

Feature Request: Support Platforms where Get-SmbShare is Not Present

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...

xSmbShare resource does not take into account properties other than Name, Path, Ensure when doing a Test-TargetResource

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.

No option to disable continuous availability

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.