First, I'd recommend doing it _all_ in PowerShell, which ultimately simplifies matters:
The complexity of dealing with 2 very different environments aside, invoking PowerShell commands with `powershell -command` and a command string containing the command to execute introduces quoting complexities that can be tricky to resolve.
Second, your issue is that your pipeline tries to do _2 disparate_ things at once:
* pass a file's _path_ through
* while also transforming that file's _content_.
Your attempt muddles the two task: it passes in file objects (that resolve to their _paths_ in a string context), then mistakenly treats them as if they were their _contents_, then magically expects the modified contents to turn back into file objects (paths) telling `Set-Content` what files to write back to.
While it _is_ possible to do this with a single pipeline, it would be virtually unreadable, so I recommend performing the two tasks in separate steps:
<sup>Note: I know that your `Get-ChildItem` command will in practice only yield _1_ file, but _potentially_ it will yield _multiple_ ones, so I'll try to solve that case.
Furthermore, I've avoided the use of `cmd.exe` variables (`%AppDate%`) and instead use only PowerShell's (`$env:AppData`).
Also, note the use of a _back-reference_ (`\1`) in the regular expression below, which avoids the need to repeat `AdvertPlaceholder`, as well as the use of `$1` om the substitution expression to refer to the first capture group in the regex (`AdvertPlacholder`)</sup>
If we focus on just PowerShell for now, we get:
$files = Get-ChildItem $env:AppData\Skype -Recurse config.xml
foreach($file in $files) {
(Get-Content $file.fullname) -replace '<(AdvertPlaceholder)>1</\1>', '<$1>0</$1>' |
Set-Content $file.fullname
}
Note:
* In terms of character encoding, `Set-Content` defaults to system's default code page. When in doubt, use an explicit encoding, such as `-Encode UTF8`.
* The above assumes that the XML element in question is on a _single_ line. If it isn't, things get more complicated: while you can use `Get-Content -Raw` (PowerShell v3+) to read the entire input file at once, `Set-Content` will add an _extra_ newline to the output; also, you'd have to adapt the regex passed to `-replace` above to account for line-spanning whitespace.
* [Matt's helpful answer](https://stackoverflow.com/a/34447673/45375) shows a more _robust_ way of handling the value substitution, using proper XML parsing via the `[xml]` type (fully qualified name: `System.Xml.XmlDocument`).
If you still want to call the above PowerShell command from a _batch_ file, here's how to do it:
Note the need to use a _single-line_ literal to pass to `powershell.exe -command`, which makes the whole thing unreadable; also, adding `-noprofile` is generally a good idea so as to suppress loading of the profile file, which is intended only for _interactive_ use.
powershell -noprofile -command "$files = Get-ChildItem $env:AppData\Skype -Recurse config.xml; foreach($file in $files) { (Get-Content $file.fullname) -replace '<(AdvertPlaceholder)>1</\1>', '<$1>0</$1>' | Set-Content $file.fullname }"