This is a pre-defined variable for an API call.
$CorePluginConfigurationContext = ([xml]"
<CorePluginConfigurationContext xmlns='http://schemas.solarwinds.com/2012/Orion/Core' xmlns:i='http://www.w3.org/2001/XMLSchema-instance'>
<BulkList>
<IpAddress>
<Address></Address>
</IpAddress>
</BulkList>
</CorePluginConfigurationContext>
").DocumentElement
Reading PowerShell books, online documentation, XML namespaces, Nodes, Parents, Childs, Appending, "element""s", I simply could not able to add data to this specific variable.
I'm getting multiple values as parameters
Param(
[Parameter(Mandatory=$true)]
[String[]]$nodes = "1.1.1.1"
)
And need to add these values to the XML object.
foreach ($node in $nodes) { }
And the result would look like this:
<CorePluginConfigurationContext xmlns='http://schemas.solarwinds.com/2012/Orion/Core' xmlns:i='http://www.w3.org/2001/XMLSchema-instance'>
<BulkList>
<IpAddress>
<Address>10.10.1.19</Address>
</IpAddress>
<IpAddress>
<Address>10.10.1.20</Address>
</IpAddress>
</BulkList>
</CorePluginConfigurationContext>
The test code:
Param (
[Parameter(Mandatory=$true)]
[String[]]$nodes = "1.1.1.1"
)
$CorePluginConfigurationContext = ([xml]"
<CorePluginConfigurationContext xmlns='http://schemas.solarwinds.com/2012/Orion/Core' xmlns:i='http://www.w3.org/2001/XMLSchema-instance'>
<BulkList>
<IpAddress>
<Address></Address>
</IpAddress>
</BulkList>
</CorePluginConfigurationContext>
").DocumentElement
foreach ($node in $nodes) {
# Code to add multiple $node values to the XML above
}