I have excel csv file that has one column (User ID) in OU in Active directory, I need to create powershell script that going to check and verify on each one of them if they are already exist in Active directory or not and if it's exist write the group name that he belong to
PowershellActive Directory
Last Comment
Naser Gabaj
8/22/2022 - Mon
Jacob Durham
What do you have so far? And what is the formatting of the CSV? Is it like below?
to be able to use my csv file as an input to this script I should replace the part where it says "$users = "jacobd","talonssss"" to be :
Import-Csv -Path "Y:\MissingMembers.csv" | ForEach-Object {<YOUR SCRIPT>}...right?
You might need to use $user.userid depending on how the CSV looks.
Naser Gabaj
ASKER
I feel I'm almost there but the result is not as I expect, please see attached, is there a way I can direct my search to look into a specific OU name?
Should I replace the part
" $ADUser = Get-ADUser -Identity $user -Properties primarygroup -ErrorAction Stop"
with the
" $ADUser = Get-ADUser -Identity $user -Properties OU -SearchBase 'OU=XYZ' -ErrorAction Stop"
userid
----------
user1
user2