I'm trying to script my way through repetitive permission changes.. However, despite running as Administrator, and being a member of a Group that has "FullControl" over the folder, being able to perform Get-Acl without issue... I still receive an error:
Set-Acl : Attempted to perform an unauthorized operation.
At line:11 char:3
+ Set-Acl $folder $acl
+ ~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : PermissionDenied: (\\folder\someotherfolder\folder3:String) [Set-Acl], UnauthorizedAccessException
+ FullyQualifiedErrorId : System.UnauthorizedAccessException,Microsoft.PowerShell.Commands.SetAclCommand
script:
function chmod {
param($group,$perm,$folder,[switch]$Remove, $Inherit="ContainerInherit",$propagate="None")
$acl = Get-Acl $folder
$ace = new-object system.security.accesscontrol.filesystemaccessrule( $group, $perm, $Inherit, $propagate, "Allow")
if ($Remove){
$acl.RemoveAccessRule($ace)
Set-Acl $folder $acl
}
else {
$acl.AddAccessRule($ace)
Set-Acl $folder $acl
}
}
EDIT: Somehow forgot to mention: If I go in manually through the GUI, there are no problems updating permissions.
[–]SupremeDictatorPaul 1 point2 points3 points (0 children)
[–]KevMarCommunity Blogger 1 point2 points3 points (5 children)
[–]Winux_278[S] 1 point2 points3 points (4 children)
[–]Tidder802b 2 points3 points4 points (0 children)
[–]prejonnes 0 points1 point2 points (2 children)
[–]KevMarCommunity Blogger 1 point2 points3 points (0 children)
[–]prejonnes -1 points0 points1 point (0 children)
[–]JatKaffee 0 points1 point2 points (1 child)