Reputation: 3
I'm tying to get the permissions of all the folders in a path on a remote server as efficiently as I can so I want to make as few calls as I can (avoiding looping through all folders and running a get-acl call for each). I'm running the following command in a powershell remote session $Session
$ACL = Invoke-command -Session $Session -Scriptblock{get-childitem -path "drive:\folderpath" | GET-ACL}
However once I try to use the object to look at the access list with $ACL.access
then all folders just say System.Security.AccessControl.FileSystemAccessRule
and have no properties.
If instead I run the below then $ACLAccess
shows the permissions as I would expect.
$ACLAccess = Invoke-command -Session $Session -Scriptblock{(get-childitem -path "drive:\folderpath" | GET-ACL).access}
Why is the access property displaying differently inside invoke-command compared to outside of invoke-command?
This other question does not answer why getting the property inside the invoke seems to work but outside doesn't.
Upvotes: 0
Views: 440