Skip to content

Setting NTFS perms on new drive/directory fails the first time #13

@adhodgson1

Description

@adhodgson1

Hi all,

OS: Windows Server 2016

I am trying to set perms on a directory that I create after formatting a new drive and always I get the following output which causes the DSC to fail. if I run it again it seems to complete ok and that is the end of the matter until the server is rebuilt:

ConfigurationName : MyDSC
DependsOn : {[File]Server Folder}
ModuleName : cNtfsAccessControl
ModuleVersion : 1.0.7.0
PsDscRunAsCredential :
ResourceId : [cNtfsPermissionEntry]SetServerNTFSPermissions
SourceInfo : ::205::5::cNtfsPermissionEntry
DurationInSeconds : 1.109
Error : {
"Exception": {
"Message": "The PowerShell DSC resource
\u0027[cNtfsPermissionEntry]SetServerNTFSPermissions\u0027 with SourceInfo
\u0027::205::5::cNtfsPermissionEntry\u0027 threw one or more non-terminating errors while
running the Test-TargetResource functionality. These errors are logged to the ETW channel
called Microsoft-Windows-DSC/Operational. Refer to this channel for more details.",
"Data": {

                                                  },
                                         "InnerException":  null,
                                         "TargetSite":  null,
                                         "StackTrace":  null,
                                         "HelpLink":  null,
                                         "Source":  null,
                                         "HResult":  -2146233079
                                     },
                       "TargetObject":  null,
                       "CategoryInfo":  {
                                            "Category":  7,
                                            "Activity":  "",
                                            "Reason":  "InvalidOperationException",
                                            "TargetName":  "",
                                            "TargetType":  ""
                                        },
                       "FullyQualifiedErrorId":  "NonTerminatingErrorFromProvider",
                       "ErrorDetails":  null,
                       "InvocationInfo":  null,
                       "ScriptStackTrace":  null,
                       "PipelineIterationInfo":  [
                   
                                                 ]
                   }

FinalState :
InDesiredState : False
InitialState :
InstanceName : SetServerNTFSPermissions
RebootRequested : False
ResourceName : cNtfsPermissionEntry
StartDate : 6/29/2018 1:01:26 PM
PSComputerName :

Here is the relevant DSC:

[PSCredential]$serviceaccount = Get-AutomationPSCredential -Name $Node.ServiceAccountName

$installLocation = "E:\Server"

xDisk "FormatServerDrive" {
  DiskNumber = 2
  DriveLetter = 'E'
  FSLabel = 'Server'
}

File "Server Folder" {
  Ensure = "Present"
  DestinationPath = $installLocation
  Type = "Directory"
  DependsOn = "[xDisk]FormatServerDrive"
}

cNtfsPermissionEntry SetServerNTFSPermissions {
  Ensure = "Present"
  Path = $installLocation
  Principal = $serviceaccount.UserName
  AccessControlInformation = @(
    cNtfsAccessControlInformation {
      AccessControlType = "Allow"
      FileSystemRights = "FullControl"
      Inheritance = "ThisFolderSubfoldersAndFiles"
      NoPropagateInherit = $false
    }
  )
  DependsOn = "[File] Server Folder"
}

Any suggestions?
Thanks.
Andrew.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions