How to alter multiple nodes in a DTSX xml file with powershell -


i want following: select configuration nodes and, depending on objectname value, change configurationstring node value.

the xml following:

<dts:executable xmlns:dts="www.microsoft.com/.." dts:executabletype="ssis.package">     <dts:configuration>     <dts:property dts:name="configurationtype">1</dts:property>     <dts:property dts:name="configurationstring">change me</dts:property>     <dts:property dts:name="objectname">configuration_1</dts:property>     <dts:property dts:name="dtsid">{..}</dts:property>   </dts:configuration>   <dts:configuration>     <dts:property dts:name="configurationtype">1</dts:property>     <dts:property dts:name="configurationstring">me please</dts:property>     <dts:property dts:name="objectname">configuration_2</dts:property>     <dts:property dts:name="dtsid">{..}</dts:property>   </dts:configuration> 

i had following code alter configurationstring when there 1 instance of type of node.

$item = [xml](get-content -path($item_path)) $item.executable.configuration.property | ? { $_.name -eq 'configurationstring'} | % { $_.'#text' = "text" } $item.save( $item_path ) 

i tried add condition @ ? { $_.name -eq 'configurationstring'} check if objectname desired one, couldn't configuration node , change configurationstring node value.

i have tried using selectsinglenode method, didn't work:

$item.selectsinglenode("executable/configuration/property[@objectname='configuration_1']") | ? { $_.name -eq 'configurationstring'} | % { $_.'#text' = "test" } 

thanks , regards.

it's simple matter of using selectsinglenode parent

 $xml.executable.configuration | % { $_.property } | # of properties   ? { $_.name -eq "objectname" -and $_."#text" -eq "configuration_1" } | #get 1 looking    % { $_.selectsinglenode("..").property } | # of it's sibling properties   ? { $_.name -eq 'configurationstring'} |   # property want change   % { $_.'#text' = "text" }                  # update property 

it's maybe not cleanest should job done.


Comments

Popular posts from this blog

Unable to remove the www from url on https using .htaccess -