Import xml file


I am getting the below error, when I try to import the file.

PS D:> import-clixml -path d:\process.xml
Import-Clixml : Data at the root level is invalid. Line 2, position 1.
At line:1 char:14

  • import-clixml <<<< -path d:\process.xml
    • CategoryInfo : NotSpecified: (:slight_smile: [Import-Clixml], XmlException
    • FullyQualifiedErrorId : System.Xml.XmlException,Microsoft.PowerShell.Commands.ImportClixmlCommand

What’s in that file? Was it created by the Export-Clixml cmdlet? If it’s just a general XML file, don’t use Import-Clixml. Do this instead:

[xml](Get-Content d:\process.xml)

Hi Dave,

I had used out-file to export the file in xml. So if I dont use export file, I should not use import-clixml? Please clarify

gps |out-file d:\process.xml

If you used Out-File, then it’s not really an XML file at all, regardless of what file extension you gave it. :slight_smile: It’ll just be a text file containing a table or list (whatever you’d have seen at the console if you hadn’t piped to Out-File.)

Export-Clixml and Import-Clixml are paired commands; the import reads files created by the export.

You could have done this:

gps | Export-Clixml d:\process.xml

# and later:

Import-Clixml d:\process.xml

Thank so much for the explanation!!It helped :slight_smile: