Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

add xml attribute to an element using powershell

$
0
0

Hi,

I am trying to modify an xml config using powershell. I am familiar with modifying already set values. And I am familiar with creating an element, setting key/value attributes, and appending that element. What I am struggling to do is add an attribute to an existing element.

For example: say I want to add an attribute called bindingConfiguration with value AppBinding to my endpoint element

from:
<configuration>
 <system.serviceModel>
  <services>
   <service name="ServiceName">
    <endpoint binding="basicHttpBinding">
    </endpoint>
    <host>
     <baseAddresses>
      <add baseAddress="localhost:81" />
     </baseAddresses>
    </host>
  </service>
 </system.serviceModel>
</configuration>

to:
<configuration>
 <system.serviceModel>
  <services>
   <service name="ServiceName">
    <endpoint binding="basicHttpBinding" bindingConfiguration="AppBinding">
    </endpoint>
    <host>
     <baseAddresses>
      <add baseAddress="localhost:81" />
     </baseAddresses>
    </host>
  </service>
 </system.serviceModel>
</configuration>

Thanks,

Jason


Jason


Viewing all articles
Browse latest Browse all 15028

Latest Images

Trending Articles



Latest Images