List of homedirs without a user

I need a script to show a list of home directories that do not have a user assigned to them, this part was fairly easy. Where I am having trouble is sometimes we have a home directory without the original user but someone else has been assigned to it when the user left. I am trying to clear all of these up. I was able to get a list of HomeDirs without the original owner but now want to see which of those may have another user added to it. For the second part I am using Get-Acl to find who has rights but that lists all of our normal accounts that have access to everything.
I need a way to do a Where -eq anything except what is in the “exceptions list”. This is what I have so far:

Add-PSSnapin Quest.ActiveRoles.ADManagement
$Exceptions = @("BUILTIN","ADMINUser","Domain Admins","Enterprise Admins","migrationadmin")
dir \\MYFILESERVER\users\ | Where {$_.PSIsContainer -AND -not (Get-QADUser -SearchRoot "MYOUPath" -SamAccountName $_.PSChildName)} | get-acl| ForEach {

 $path=$_.Path

 $_ | select -expand access | 

 where {$_.identityreference -notmatch $Exceptions} |

 Select @{Name="Path";Expression={$Path}},IdentityReference,FileSystemRights

}

This gets me a list of homedirs without users but ignoring the exceptions.
I know my problem is with this line:

where {$_.identityreference -notmatch $Exceptions}

but being so new to powershell I am just not sure how to do it.

Thanks,
Scott

try -notin instead of -notmatch.

That did it and actually makes sense now :slight_smile:
Thanks alot!
Scott