You use the comparison operator -contains in your condition statement. -contains looks for an element in an array of elements and it has to be a perfect match to provide a positive hit. Do your lists contain exact matches you can use for this kind of comparison? You may share some sanitized but still representative lines of your lists - formatted as code as well please.
BTW: You should use the code tags “PRE” to format your code as code. Thanks
Olaf,
Thank you for the code but I’m ending up with the same results as I was. It is like the contains lookup is not working because here is an example of a piece of data from the variables that I outputted to a CSV:
$FGroupMembers
Name SamAccountName enabled Description objectguid DistinguishedName
Abb, Pat pabb TRUE Sr. Manager 4e4f4173-caa2-4c65-b9c7-744d55931a60 CN=Abb\, Pat,OU=Site,OU=DIV,OU=Users,DC=Domain,DC=com
$DGroupMembers
Name SamAccountName enabled Description objectguid DistinguishedName
Abb, Pat 4e4f4173-caa2-4c65-b9c7-744d55931a60 CN=Abb\, Pat,OU=Site,OU=DIV,OU=Users,DC=Domain,DC=com
$O365GroupMembers
I’m looking into what is going on with this group member collection command because it is currently not returning any members
Which explains one of the contain lookup failures.
Olaf,
One new question relating to this code. I have two different data sets that I’m using the SAME code on to produce a csv file. My problem is the CSV files generated come out in different column order. My first set which I originally started with comes out in the order of:
Enrolled
O365
Enabled
Name
Distinguishedname
My second which is the same type of data just different comes out like:
Enrolled
Name
O365
Distinguishedname
Enabled
All the same code. Is there a way to order the columns so that I get similar report out between the two reports for consistency?
You know that the order of the columns does not matter for Powershell or for functionality, don’t you? If you want to have a particular order you can use Select-Object and specify the properties you want to show in the order you want to show. Of course you can use this before you save/export the data to the csv files. It’ll just gonna be a little quirky when you have some more - many more - columns to deal with.