I am trying to compare values within a csv. I am taking a csv with device id,description, and location importing the csv then pulling computer description from active directory. I want to compare the 2 descriptions. I am having difficulty with the compare part. The comparison results evaluate to False without exception for both identical and non-identical strings. Can someone please tell me where I am going wrong?
I am on the PowerShell journey myself but here is a suggestion for performance.
You could pipe to ForEach-Object as Olaf illustrates (which can get the job done) - I do use this when needed. If you’re having to process many objects, I would opt for the foreach construct instead.
When using ForEach-Object, each object is generated from the collection, individually, before entering the pipeline, then processed. Multiply this by hundreds or thousands of objects, and it will take a long time.
Generate, process. Generate, process. etc.
When using the foreach construct, all the objects in the collection are generated only once and then processed one at a time. This can be a much faster operation without the overhead of generating individual objects before processing them.