in a given folder, I want to list the names of all subfolders where UserX does not appear in the ACL.
************
#easy enough to get all folders
set-location "\\server\share\"
$DocumentsFOlders=get-childitem | where {$_.psiscontainer}
#here I can't get the comparison to work,
#no matter if I use -notlike or -ne or -notmatch or -notcontains
foreach ($DocumentsFOlder in $DocumentsFOlders) {
$documentsfolder.name | where {(($documentsfolder.getaccesscontrol() | select -expand access |
select identityreference)) -notmatch "*UserX*"}
}
*************
used separately, the command "$documentsfolder.getaccesscontrol() | select -expand access | select identityreference" returns a list of all Users in the ACL, and I can plainly see whether or not UserX is in the list. but it's a NoteProperty, and I can't seem to get it to compare to a string properly. in fact in some cases, it returns the same list of folder names whether I use -like or -notlike.