Simpler techniques with Powershell

gisliScriptingLeave a Comment

There are ways to do write code in Powershell much simpler and of course if you have been using Powershell and you feel comfortable with these different types of commands, it could be little bit hard to learn a new ones that do the same, for instance if you are writing a foreach command then there are few ways to do it. Lets say that I have an array with a few cars and I want to iterate through the array with foreach here is how you can do it much simpler

The same way you can do it with where, here is an example how you can do it

With the percentage or the question mark instead of the whole word can make the code much simpler but there is a small downside and is that if you have a heavy or large code to do something can make the code harder to read, especially when another coder is reading the code, that is why it is good practice to have comments.

Anyways happy development

Leave a Reply

Your email address will not be published. Required fields are marked *