I'm trying to parse Palo Alto firewall rules with Powershell. Some rules can have ~100 servernames in them. I need to break down each name to check if they're still alive (DNS) and return rule mapping for each servername. Most of it works except for:
Currently I have:
RuleName, {Hostname1;Hostname2;Hostname3}
I'm trying to get:
RuleName, Hostname1 ;
RuleName, Hostname2 ;
RuleName, Hostname3
I started with a hashtable, but having issues with overall script length - too long
I've been doing:
Select-Object RuleName,@{Name="Hostnames";Expression={($_.Hostnames).Split(";")}
But feels like I need a ForEach-Object
in the Expression to add the RuleName field to each hostname, so it doesn't turn into a collection.