Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Powershell - How to create a blank new line in an array by comparing lines

$
0
0

I have a script which outputs a list of hosts within a vCenter and details the cluster that each host is in, what I can't figure out is how to insert a blank line into the array whenever the "Cluster Name" of each host changes.

To say it a different way, I want to separate items in a list out by using blank lines, and I want to insert one of these blank lines every time the "Cluster Name" property of each item changes.

                                     

For example at the moment my output is something roughly like this:

Host             Cluster

Host1           Cluster1

Host2           Cluster1

Host3           Cluster2

Host4           Cluster2

               

But I want it to appear like:

Host             Cluster

Host1           Cluster1

Host2           Cluster1

                               

Host3           Cluster2

Host4           Cluster2







Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>