Cannot load hashtable from file. RRS feed

  • Question

  • Hi,

    I have a ps1 to export the hashtable as a file.

    Name                           Value
    ----                           -----
    G                              Green    
    R                              Red             
    B                              Blue

    However, powershell's ConvertFrom-StringData cannot read back from file.  it must read as format like:




    How can I read the content from file which exported from hashtable?

    Friday, November 22, 2013 8:22 AM


  • To save an object to a file you can use the Clixml cmdlets:

    $ht | Export-Clixml $env:TEMP\test.xml
    $ht=Import-Clixml $env:TEMP\test.xml

    In case you really want to read it back the way you exported it:

    Get-Content c:\test.txt | select -Skip 2 | foreach {

    • Edited by Dirk_74 Friday, November 22, 2013 9:09 AM
    • Proposed as answer by Wizend Friday, November 22, 2013 1:48 PM
    • Marked as answer by AnnaWY Sunday, December 1, 2013 2:38 AM
    Friday, November 22, 2013 9:03 AM