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\Administrators:(OI)(CI)F
         NT AUTHORITY\SYSTEM:(OI)(CI)F
         CREATOR OWNER:(OI)(CI)(IO)F
         BUILTIN\Users:(OI)(CI)R
         BUILTIN\Users:(CI)(special access:)

                           FILE_APPEND_DATA

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

                           FILE_WRITE_DATA

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.

0 comments: