Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Why does Get-Acl return values not useable in Set-Acl?

$
0
0

$Acl =Get-Acl

$AclPath
$AclAccess=$Acl.Access | Where-Object {!$_.IsInherited }

The above code returns permissions like
         NT AUTHORITY\Authenticated Users Allow  Modify, Synchronize
         NT AUTHORITY\Authenticated Users Allow  -536805376

When I attempt to copy the ACL from one folder to another using Get-Acl .Access and FileSystemAccessRule with Set-Acl, most permission work, but it always errors on numerical values like the one above.

New-Object : Exception calling ".ctor" with "5" argument(s): "The value '-536805376' is not valid for this usage of the type FileSystemRights.
Parameter name: fileSystemRights"
At C:\Replace-LocalGroups.ps1:57 char:26
+     $AccessRule = New-Object <<<<  system.security.AccessControl.FileSystemAccessRule($AccessRuleIdentity, $Permission, $Inheritence, $Propogation, $AccessType)
    + CategoryInfo          : InvalidOperation: (:) [New-Object], MethodInvocationException
    + FullyQualifiedErrorId : ConstructorInvokedThrowException,Microsoft.PowerShell.Commands.NewObjectCommand

What is the proper way to handle / set these types of permissions in PowerShell?



Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>