Hello All,
I'm struggling with parsing an xml file of our DFSn environment. The issue (so far) is that PoSH falls over when parsing '&'. And the problem is that my original xml will contain strings that need to be corrected along with strings that don't....
An example of the xml I'm manipulating is:
<?xml version="1.0"?>
<Root xmlns = "http://schemas.microsoft.com/dfs/2007/03/dfsutil" majorVersion = "2" minorVersion = "0"
Name="\\MyDFSn.my.domain.com\City" State="OK" Timeout="300" >
<Target State="ONLINE" >\\MyDFSn.my.domain.com\City</Target>
<Link Name="data\obreggav" Comment="DFS link to homeshare for Gavin O'Bren " State="OK" Timeout="300" >
<Target State="ONLINE" >\\MyServer.my.domain.com\data_MyServer_vol102\obregav</Target>
</Link>
<Link Name="DataShared\datagroup\stpf&s" State="OK" Timeout="300" >
<Target State="ONLINE" >\\OtherServer.my.otherdomain.com\shared4_OtherServer_vol304\stpf&s</Target>
</Link>
</Root>
As you can see I need to only change the '&' in the last Link where it says 'stpf&s' BUT I need to leave all other instances of '&' as they are ('stpf&s' and 'O'Bren ')
How is the best / simplest way to do this? I feel that I want to do a -replace or use the replace method of get-content (or something) AND where-object to separate '&' -AND ''' but I can't figure that out!
Any help would be very welcome :)
Many thanks
Tomsk