Hi everyone,
I’ve used a sample NTFSPermission PS DSC script to manage file sharing. When I used it to Deny users to access a file, it works, but when I reuse the script again to try to revert it (giving back the access), it won’t work. Why is that?
Here’s the code:
configuration SetNTFSPermission
{
param
(
# Target nodes to apply the configuration
[string[]]$NodeName = 'localhost',
# Add Account
[Parameter(Mandatory)]
[ValidateNotNullOrEmpty()]
[String]$Account,
# Create a Physical Path
[Parameter(Mandatory)]
[ValidateNotNullOrEmpty()]
[String]$PhysicalPath,
# Add Access
[Parameter(Mandatory)]
[ValidateNotNullOrEmpty()]
[String]$Access,
# Add Rights
[Parameter(Mandatory)]
[ValidateNotNullOrEmpty()]
[String]$Rights
)
# Import the module that defines custom resources
Import-DscResource -Module xPSDesiredStateConfiguration
Node $NodeName
{
NTFSPermission NewPermission
{
Ensure = "Present"
Account = $Account
Access = $Access
Path = $PhysicalPath
Rights = $Rights
}
}
}
SetNTFSPermission
Start-DscConfiguration -Force -Wait -Verbose -Path .\SetNTFSPermission