Reputation: 123
I need to show all the domain\username|groupname of everyone who is allowed access to a particular folder to feed into another command (I'll be removing access for all users and setting new user rights), is there anyway to format a list that returns just this parameter? I know it's probably some combination of select-object and format-list, but I'm not sure exactly what I'm looking for.
Upvotes: 3
Views: 22517
Reputation: 26031
You can retrieve that from the IdentityReference
property of the Access
property of get-acl
. Here's an example from my user folder:
PS C:\> $users = @((get-acl 'C:\users\myUser').Access |
Select-Object -ExpandProperty IdentityReference)
PS C:\> $users
Value
-----
NT AUTHORITY\SYSTEM
BUILTIN\Administrators
DOMAIN\myUser
The objects returned in the collection are of the type NTAccount.
Upvotes: 5