tonelm54
asked on
Get ACL for File or Folder
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:-
My compete code is:-
Is it possible to get the variable to a string?
Thank you
$fileACLAccess = (Get-ACL $_.FullName).Access
, I just get System.Security.AccessControl.FileSy stemAccess Rule System.Security.AccessCont rol.FileSy stemAccess Rule System.Security.AccessCont rol.FileSy stemAccess Rule System.Security.AccessCont rol.FileSy stemAccess Rule
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:\")
Is it possible to get the variable to a string?
Thank you
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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($strDirector
}
else {
$fileACLOwner = (Get-ACL $_.FullName).Owner
$fileACLAccess = (Get-ACL $_.FullName).Access
$fileACLGroup = (Get-ACL $_.FullName).Owner
}
}
}
scanDirectory("c:\temp")