I have a CSV of hostname,ip of routers in our network and I want to create an XML template for importing these all into putty.
I have the xml schema required
My existing plan was to import the CSV and call it $router then place $router.hostname and $router.ip into the script, but I can't work out how to make this populate the text with the csv values nor how to then export it as XML.
Ideally it would then output each xml as a file per router $hostname.xml.
Does anyone have any pointers on how to make this work? I have a fair amount of experience with PS and CSV but never XML, I'm aware this is gonna need a foreach but I am fairly new at this all.
Thanks Sam
$router=import-csv C:\Users\Admin\Desktop\RouterIPHost.csv
<?xml version="1.0" encoding="UTF-8" standalone="true"?>
<root expanded="True" name="Test MSP" type="database"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<connection name=($router.hostname) type="PuTTY">
<name>$Putty.name </name>
<protocol>Telnet</protocol>
<host>($router.ip)</host>
<port>23</port>
<session>Default Settings</session>
<connectiontimeout>1500</connectiontimeout>
<logintimeout>1000</logintimeout>
<passwordtimeout>1000</passwordtimeout>
<commandtimeout>1000</commandtimeout>
<postcommands>False</postcommands>
</connection>
</root>
Export-Clixml -path "C:\Users\PRTG_Admin\Desktop\xmlrouter.xml"