Powershell better coding

I have seen some horrible bad coding in powershell in the past, well it´s probably my fault because I did not understand how to code correctly when I started to code, hehe, yes I´m making fun of my self. I took some codes that I was working with and I just wanted to show you how you can approach this in different ways. The problem I had in the past was I had a array object which contained a lot of information and I wanted to compare the object to something I was working with. Here are two objects that contain the array, one is from database and one is from the environment. I will just type in the content of the objects so you can understand

Now as you can see I wanted to compare these two objects so I could get the notes from the database and the objects in the $ENVObjects. This is the code which I did in the past.

As you can see it´s huge code to compare two objects and return the notes I wanted, but there is a better way to do this.

Well as you can see this is little bit better than before right, but it can be done in much simpler way, but the line is little bit longer

You can also do compare-object command but that would require you to do some little bit of modifying the property names if they are different.

Trackback from your site.