Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Get ACL for File or Folder

Posted on 2013-12-13
2
Medium Priority
?
863 Views
Last Modified: 2013-12-13
I want to be able to dump to a string the ACL information for a file or folder, however when I run the script and it gets to the following line:-
$fileACLAccess = (Get-ACL $_.FullName).Access

Open in new window

, I just get
System.Security.AccessControl.FileSystemAccessRule System.Security.AccessControl.FileSystemAccessRule System.Security.AccessControl.FileSystemAccessRule System.Security.AccessControl.FileSystemAccessRule

My compete code is:-
Function scanDirectory($strDirectory) {
    write-host "Snap shotting " $strDirectory
	dir $strDirectory | % { if ($_.PsIsContainer) { 
			echo "Directory Found - $_\" 
            $fileACLOwner = (Get-ACL $_.FullName).Owner
            $fileACLAccess = (Get-ACL $_.FullName).Access
            $fileACLGroup = (Get-ACL $_.FullName).Group
            
            write-host $fileACLOwner
            write-host $fileACLAccess
            write-host $fileACLGroup
            
			scanDirectory($strDirectory + "\" + $_) 
			} 
		else { 
                     $fileACLOwner = (Get-ACL $_.FullName).Owner
                     $fileACLAccess = (Get-ACL $_.FullName).Access
                     $fileACLGroup = (Get-ACL $_.FullName).Owner
			} 
		}
	}
    
scanDirectory("d:\")

Open in new window


Is it possible to get the variable to a string?

Thank you
0
Comment
Question by:tonelm54
2 Comments
 
LVL 40

Accepted Solution

by:
Subsun earned 2000 total points
ID: 39716468
Access is a multivalued property.. Try to convert it to string and see if it works for you..
$fileACLAccess = (Get-ACL $_.FullName).Access | Out-String

Open in new window

0
 
LVL 19

Expert Comment

by:Raheman M. Abdul
ID: 39716477
Function scanDirectory($strDirectory) {
    write-host "Snap shotting " $strDirectory
      dir $strDirectory | % { if ($_.PsIsContainer) {
                  echo "Directory Found - $_\"
            $fileACLOwner = (Get-ACL $_.FullName).Owner
            $fileACLAccess = (Get-ACL $_.FullName).Access
            $fileACLGroup = (Get-ACL $_.FullName).Group
           
            $fileACLOwner
            $fileACLAccess
            $fileACLGroup
           
                  scanDirectory($strDirectory + "\" + $_)
                  }
            else {
                     $fileACLOwner = (Get-ACL $_.FullName).Owner
                     $fileACLAccess = (Get-ACL $_.FullName).Access
                     $fileACLGroup = (Get-ACL $_.FullName).Owner
                  }
            }
      }
   
scanDirectory("c:\temp")
0

Featured Post

New Tabletop Appliances Blow Competitors Away!

WatchGuard’s new T15, T35 and T55 tabletop UTMs provide the highest-performing security inspection in their class, allowing users at small offices, home offices and distributed enterprises to experience blazing-fast Internet speeds without sacrificing enterprise-grade security.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In the absence of a fully-fledged GPO Management product like AGPM, the script in this article will provide you with a simple way to watch the domain (or a select OU) for GPOs changes and automatically take backups when policies are added, removed o…
Measuring Server's processing rate with a simple powershell command. The differences in processing rate also was recorded in different use-cases, when a server in free and busy states.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Screencast - Getting to Know the Pipeline

885 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question