Tuesday, December 04, 2012

Get Folder Permissions by Scripts (1)

I found there is a DOS command tool to get folder permissions: Calcs. By using this tool, permissions can be added, deleted or modified as well. Based on this findings, I used PowserShell to create a script to get folder permissions. I am planning to further to enhance this script to create duplicated permissions for a specified folder.

Here is a example of using the script in a batch script:

C:\test\powershell c:\scripts\GetPerm.ps1'C:\MyData' /s

The result is something like this:

D:\MyData Everyone:(OI)(CI)F
         BUILTIN\Users:(CI)(special access:)


         BUILTIN\Users:(CI)(special access:)


If there are sub-folders within, the script will loop through to get all sub-fodler permissions as well.

It is possible to use WMI class or other tools in PS to get folder permissions. Calcs is a free tool in Windows. I found it is much easy to leverage its power to do the job.