I have XML
file with content below:
<Tenants>
<Tenant name="tenant_1" url="8s0n3lewbf7v.local" site="98074" path="\\1f7csgqde3l7.local\share\shared\98074" />
<Tenant name="tenant_2" url="8s0n3lewbf7v.local" site="62761" path="\\1f7csgqde3l7.local\share\shared\62761" />
<Tenant name="tenant_3" url="8s0n3lewbf7v.local" site="24387" path="\\1f7csgqde3l7.local\share\shared\24387" />
<Tenant name="tenant_4" url="8s0n3lewbf7v.local" site="85670" path="\\1f7csgqde3l7.local\share\shared\85670" />
<Tenant name="tenant_5" url="8s0n3lewbf7v.local" site="29117" path="\\1f7csgqde3l7.local\share\shared\29117" />
</Tenants>
The tenants
block contains an unknown count of an object in each of them path
needs to be updated.
The path
has a UNC
format which is also unknown.
The task is to replace server name 1f7csgqde3l7.local
(which is unknown) but it's the same in each path
of the Tenants
block with a variable $server
, and URL 8s0n3lewbf7v.local
with a variable $url
.
What is the best approach to achieve this by using PowerShell?