-
Notifications
You must be signed in to change notification settings - Fork 6
PS7 issue with .GetAccessControl() not in .Net Core #9
Copy link
Copy link
Open
Labels
bugThe issue is a bug.The issue is a bug.help wantedThe issue is up for grabs for anyone in the community.The issue is up for grabs for anyone in the community.
Description
This trick does not work with PS7.
The API has changed between .Net 4.x and .net core.
I think the below should work (ok in PS7):
function Get-ACLAccess
{
[CmdletBinding()]
param
(
[Parameter(Mandatory = $true)]
[System.String]
$Path
)
$EmptyAcl = [System.Security.AccessControl.DirectorySecurity]::new()
$ACL = (Get-Acl -Path $Path)
$ACL.Access.Foreach{$EmptyAcl.Access.AddRule($_)}
return $ACL
}
Here's how I tested:
$FileSystemAccessRuleProperties = @{
Path = 'C:\src\testACL'
Identity = 'AzureAD\GaelColas'
Rights = @('FullControl')
}
$invokeDscResourceParams = @{
Name = 'FileSystemAccessRule'
ModuleName = 'FileSystemDsc'
Property = $FileSystemAccessRuleProperties
}
if (-not (Invoke-DscResource @invokeDscResourceParams -Method Test).InDesiredState ){
Invoke-DscResource @invokeDscResourceParams -Method Set -Verbose
}
Invoke-DscResource @invokeDscResourceParams -Method Test
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugThe issue is a bug.The issue is a bug.help wantedThe issue is up for grabs for anyone in the community.The issue is up for grabs for anyone in the community.