I would like to understand why my loop doesn’t add all entries to my hash table.
I’ve build a hash table with users, next step is to get the computers and add them dynamical into the hash. In my Output for the loop i can see that some users have more than one Computer but only the first one gets added.
It seems like there are several logic errors. Break it down piece by piece and make sure it all works. Should other things be inside the first user foreach loop? $hashtab gets overwritten each time through the first loop. $hashtab is then being added to $csvoutput one time at the bottom. What is $count for?
Hashtab saves the user data for each user and adds it to the csvoutput, it gets overwritten for the next user. This works fine, i just wanted to add the computers and i don’t know if the user has one or ten computers. I need to export a csv file.
The $Computers.Length is Null if the user has only one computer and 2 if he has two computers
I wrote an outpout and it looks like this for the computer loop if the user has two computers
i would like to export all users i find to a csv with choosen columns and values. Also i would like to lookup all computers that belong to the user and add them dynamical with columns and value. I can find the computer by user mail attribute in the computer extension attribute.
Here’s a simple example of linking user and computer properties that works for me. Maybe it’s of use to you. This is two nested loops. Unfortunately you can’t pipe from foreach, but $( ) fixes that. AD filters are tricky. $( ) to the rescue again. EDIT: I guess your filter would work, but you might as well use “-eq”, since there’s no wildcards.