Ok, I got it. This is how it's done.
I want to thank everyone for trying to help me out. SSC FTW!!!!
$ServerName = "MilanoMosh"
$ConfigFile = "C:\MyFile.dtsConfig"
function Edit-XmlNodes {
param (
[xml] $doc = $(throw "doc is a required parameter"),
[string] $xpath = $(throw "xpath is a required parameter"),
[string] $value = $(throw "value is a required parameter"),
[bool] $condition = $true
)
if ($condition -eq $true) {
$nodes = $doc.SelectNodes($xpath)
foreach ($node in $nodes) {
if ($node -ne $null) {
if ($node.NodeType -eq "Element") {
$node.InnerXml = $value
}
else {
$node.Value = $value
}
}
}
}
}
$xml = [xml](Get-Content $ConfigFile)
# <file><foo attribute="bar" attribute2="bar" attribute3="bar" /></file>
Edit-XmlNodes $xml -xpath "/DTSConfiguration/Configuration/ConfiguredValue " -value $ServerName
$xml.save($ConfigFile)
# <file><foo attribute="new value" attribute2="bar" attribute3="bar" /></file>
Everyone has a plan until they get punched in the mouth. --Mike Tyson