0

I have an XML file with the below content

<?xml version="1.0" encoding="utf-8"?>
<Topology>
  <SERVER1 desc="name of server1"></ICONIS_ONLINE_SERVER1>
  <SERVER2 desc="name of server2">PROJECT</SSCOFFLINE_SERVER1>
</Topology>

I have the following powershell script to get the contents, modify the contents and save the content of XML file.

#This will replace the values on the topology file and saves it
$xmldata =[XML](Get-Content \\10.10.115.16\c$\Deployment\Config.xml)
$xmldata. Topology.SERVER1.InnerText = 'Mydomain'
$xmldata. Save((Resolve-Path \\10.10.115.16\c$\Deployment\Config.xml). Path

The above powershell script will replace the contents and saves it. However, it is not allowing to save it. It shows the error as

Exception calling "Save" with "1" argument(s): "The given path's format is not supported."

Any assistance is appreciated.

2 Answers 2

0

You could use the WebClient Uploadfile() command, as follows :

$wc = New-Object System.Net.WebClient
$resp = $wc.UploadFile($uri,$filePath)
0

I would suggest using New-SmbMapping from the SMBShare module.

New-SmbMapping -RemotePath '\\10.10.115.16' -Username "foo.local\bar" -Password "password"

From there you should be able to save to the file the way you're trying to above.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .