How to check or get which accounts have the modify rights on a particular folder using PowerShell?
If the user account or security group account has modify rights, it means that account or group can delete the file or files on a folder.
To list the user accounts or security groups on a folder, a PowerShell scripts can come handy.
But of course it can be done via GUI, by right clicking on the folder and clicking on the security tab which will show the list of security accounts and its access settings.
The PowerShell code below will get the list of accounts which have modify rights on the folder specified on the script.
Here's the code:
$folder ="D:\myDFolder"
$acl = (Get-Acl $folder).Access | where {$_.FileSystemRights -eq “Modify, Synchronize”} | select IdentityReference
Write-Output $acl
It's a three line code but does a very good job.
Sample output:
IdentityReference
-----------------
XDomain\maxUser
NT AUTHORITY\Authenticated Users
Output shows that maxUser and Authenticated Users have modify rights on "D:\myDFolder".
Cheers..Hope it helps..
Comments
Post a Comment