Reputation: 1300
I have a CSV file with GUIDs and I am trying to create a list that excludes those users.
$excludeADusers_file = Import-Csv "c:\temp\ExcludeUsers.csv"
$excludeADusers = $excludeADusers_file |
Select-Object objectGuid |
Sort-Object
Get-ADUser -Filter * |
Where-Object {$excludeADusers -notcontains $_.ObjectGuid} |
Select Name, objectGuid, Enabled
How do I exclude the list in the CSV file?
Upvotes: 1
Views: 2244
Reputation: 200373
You need to expand the objectGuid
property when importing the CSV:
$excludeADusers = $excludeADusers_file |
Select-Object -Expand objectGuid |
Sort-Object
otherwise you'll end up with a list of custom objects with a GUID property instead of a list of GUIDs.
As a side note, you may want to remove the Sort-Object
. Sorting the list doesn't improve lookup speed, so it's just a waste of time and system resources.
Upvotes: 3