I have a .csv file with several columns, one of which is Employeeid. I’m importing the CSV file and checking AD for any records that don’t have an entry in the Employeeid field. The following returns the correct result, which is one record:
However, the following generates ALL records in AD that don’t have anything in employeeid when the return should be one record. So, it appears that the following is not just comparing against the last 2 rows in the CSV:
A query like this returns ALL accounts not having the provided employeeid … and that would be either ALL account when the employeeid does not exist or ALL accounts minus one when an account with the given employeeid exists.
BTW: I corrected the formatting of your code. If you do it by hand you have to use three consecutive backticks - not single quotes. Or you use the editor option …
… to post code, sample data, console output or error messages you can use the preformatted text button ( </> ). Simply place your cursor on an empty line, click the button and paste your code.
Thank you, @Olaf and sorry about the code posting. What is the proper way of comparing the Employeeid in the CSV against AD to list accounts with nothing in the AD Employeeid field?
Yup @Olaf I did see that when I searched. It’s a little different than what I’m attempting. Basically, I want to take a list of names from a .CSV, check if the employeeid is present. That example from the search is looking in the whole AD. But in my attempt, as shared in my OP, the results of users with no employeeid are returned for my whole AD rather than just the list of names I’m pulling from the CSV.
If I got you right you should use the same check as before and just us try catch error handling to gracefully handle the error you get when no account is found with the given employee id.
I included the Employeeid field in the return of results and the ones that are returned when using the “-ne” operator HAVE and entry for the employeeid AND it equals what is in my source file. Very odd. I tried changing -ne to -notequal but received a syntax error.