Using a PowerShell Quote List Function to Work with an Array of Strings

Recently, during one of our test user group meetings that Rohn and I had, I was using an example of storing multiple server names into an array to then work with them. This is how I would normally accomplish this task, that is unless I pulled the names directly from Active Directory:


Rohn showed me the way he has been accomplishing this sort of task which requires less typing:


I tweaked Rohn’s example a little since I prefer to split on spaces, but it’s basically the same example:


With further testing, I determined I could use the split parameter first and save a few more characters even though the tabbed expansion or intellisense in the ISE didn’t like this, it still worked:


Rohn said he recently learned about using a function called a quote list where you can define the function and then simply pass your items to it with no punctuation required:


I decided to record a short video of this process:

Don’t forget to join us on Tuesday, March 12th at 8:30pm Central Time for our user group meeting which is held online via Microsoft Lync. We’ll be giving away two ebook copies of the PowerShell Deep Dives book.


I asked Rohn to take a look at this post and see what he thought. He said he learned about the quote list function while reading the “Windows PowerShell in Action, Second Edition” book written by Bruce Payette.


2 thoughts on “Using a PowerShell Quote List Function to Work with an Array of Strings”

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.