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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With