this may be a powershell-adjacent question about CSVs.
i have a script, it queries AD, produces an arraylist, includes column ‘managedby’ and others. when the script is finished, i can query the “$arraylist | where managedby -eq $null” and it returns all the rows where there’s no value for that column. awesome.
but i know i’m going to want to query these results later, and the script takes a long time to run, and i don’t want to wait, so i $myarraylist | export-csv c:\file.csv the arraylist to a csv.
later when i $myarraylist = import-csv c:\file.csv the csv back in, there are no longer any results “where managedby -eq $null”. if i open the csv in excel, the cells look empty, and excel column filter sees them as ‘blanks’, but powershell sees something in there. " where managedby -like “*” " also returns every row in the list.
As long as the script runs you don’t need to save the $arraylist to a CSV file. But if you do you may look for .IsNullOrEmpty instead of only $null when re-importing the data. A CSV file is plain text.
You may try to save the $arraylist with Export-CliXML. I’d expect this way it should maintain the $nulls in it.
You may share your code here and we may try to improve it.