i have difficulty getting get-acl
work on unc path share permissions of directory , underlying files , directories.
the code use looks this:
$outfile = "c:\users\xxxx\desktop\permissions.csv" $header = "folder path,identityreference,accesscontroltype,isinherited,inheritanceflags,propagationflags,filesystemrights" del $outfile add-content -value $header -path $outfile $rootpath = "\\intranet\sites\folder1\folder2\target-folder-as-root" $folders = dir $rootpath -recurse #| {$_.psiscontainer -eq $true}-recurse foreach ($folder in $folders) { $acls = get-acl $folder.fullname | foreach-object { $_.access } foreach ($acl in $acls) { $outinfo = $folder.fullname + "," + $acl.identityreference + "," + $acl.accesscontroltype + "," + $acl.isinherited + "," + $acl.inheritanceflags + "," + $acl.propagationflags + "," + $acl.filesystemrights add-content -value $outinfo -path $outfile } }
not taking account filename size limit issue might cause, following error:
get-acl : method failed unexpected error code 1. @ c:\users\xxxx\documents\ntfs_permissions.ps1:12 char:10 + $acls = get-acl $folder.fullname | foreach-object { $_.access } + ~~~~~~~~~~~~~~~~~~~~~~~~ + categoryinfo : notspecified: (:) [get-acl], invalidoperationexception + fullyqualifiederrorid : system.invalidoperationexception,microsoft.powershell.commands.getaclcommand
i find documentation on listing shared permissions on shared drive using unc path (i don't want list permissions starting root, starting subfolder) limited.
try use: $acls = (get-acl $folder.fullname).access
instead of: $acls = get-acl $folder.fullname | foreach-object { $_.access }
Comments
Post a Comment