Hello everyone!
I wanted to compare a list of users I have in a CSV to see if the Users exists in an AD group. My CSV contains emailaddress, name as headers. My ad group is say ABC
I tried using two ways - 1. using compare-object and 2. using foreach loop. Both ways didnt seem to work.
Hi Olaf,
I am trying to get the samaccount name from email addresses in the CSV. My csv contains emailadress and name column. USERID is the emailaddress column
Something like this happens when you use inappropriate varialbe names like $test1 and $t. You refenced the array inside your loop instead of the single elements.
In PowerShell we work with rich and powerful objects and properties. When you use Select-Object -ExpandProperty you turn the output into boring stupid text/strings.
I’d recommend to review the code snippet I posted and use a variable to catch the output of the foreach loop completely. You can use this variable later on to do whatever steps you need to do - including outputting only the sAMAccountName to a CSV file like this: