[Powershell]Concatenate XML blocks base on a list

So on previous post i have posted an entire code to build standard firewalls for new servers. So basically there is a small function that does the trick.

function GatherNewServers($new_server){
$src_addr = @" 
<source type="IP">
    <ip_address>$new_server</ip_address>
    <netmask>255.255.255.255</netmask>
</source>
"@
return $src_addr + "`r"
}
$src_ip = @()

$src_addr = Get-Content "$env:HOMEDRIVE\Powershell\test_ip.txt"
for($i=0; $i -lt $src_addr.Count; $i++) {
    $src = $src_addr.item($i)
    $src_ip += GatherNewServers($src)
 
    }

$src_ip

The idea is that I do not want the orchestrator to send request on every servers built, this will generate a lot of access requests in tufin securechange. so I was trying out a code snippet to see if i can replicate the same xml blocks with different addresses from a list of ip addresses.

Advertisements
This entry was posted in Powershell, Scripting and tagged . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s