Powershell gotchas: xml.save needs an absolute path

May 25, 2012

...

If given a relative path, xml.Save will do nothing, giving no error messages or anything.

$xml = [xml]'<root><item>1</item></root>'
$xml.Save('.foo.xml')                              # Outputs nothing.
$xml.Save((join-path (pwd) -ChildPath '.foo.xml')) # Actually writes

Profile picture

Written by Vidar Kongsli who is a software professional living in Oslo, Norway. Works as a consultant, system architect and developer at Bredvid. You should follow him on Twitter