Windows Vista Forums

Export/Import-CliXml oddity

  1. #1


    Keith Hill Guest

    Export/Import-CliXml oddity

    I'm saving out the results of Get-Command like so:

    gcm -type alias, filter, function, cmdlet | export-clixml > commands.xml

    I then load that back in as:

    $cmds = import-clixml commands.xml

    However some things don't seem to work as I would expect e.g.:

    > $cmds | ? {$_.CommandType -eq 'alias'}
    >


    which outputs nothing however the where expression works when you use it directly on GCM:

    gcm -type alias, filter, function, cmdlet | ? {$_.CommandType -eq 'alias'}

    CommandType Name Definition
    ----------- ---- ----------
    Alias % ForEach-Object

    I can get the deserialized version to work if I do this:

    > $cmds | ? {[System.Management.Automation.CommandTypes]$_.CommandType -eq 'alias'}


    Is this just an unfortunate consequence of round tripping?

    --
    Keith

      My System SpecsSystem Spec

  2.   


  3. #2


    RichS Guest

    RE: Export/Import-CliXml oddity

    Looking at the XML file produced I think its an issue with the way the its
    constructed as much as anything

    --
    Richard Siddaway
    Please note that all scripts are supplied "as is" and with no warranty
    Blog: http://richardsiddaway.spaces.live.com/
    PowerShell User Group: http://www.get-psuguk.org.uk


    "Keith Hill" wrote:

    > I'm saving out the results of Get-Command like so:
    >
    > gcm -type alias, filter, function, cmdlet | export-clixml > commands.xml
    >
    > I then load that back in as:
    >
    > $cmds = import-clixml commands.xml
    >
    > However some things don't seem to work as I would expect e.g.:
    >
    > > $cmds | ? {$_.CommandType -eq 'alias'}
    > >

    >
    > which outputs nothing however the where expression works when you use it
    > directly on GCM:
    >
    > gcm -type alias, filter, function, cmdlet | ? {$_.CommandType -eq 'alias'}
    >
    > CommandType Name
    > Definition
    > ----------- ---- ------
    > ----
    > Alias %
    > ForEach-Object
    >
    > I can get the deserialized version to work if I do this:
    >
    > > $cmds | ? {[System.Management.Automation.CommandTypes]$_.CommandType -eq

    > 'alias'}
    >
    > Is this just an unfortunate consequence of round tripping?
    >
    > --
    > Keith
    >


      My System SpecsSystem Spec


Export/Import-CliXml oddity
Similar Threads
Thread Forum
Export-clixml producing weird xml output PowerShell
Formatting Inline for Export-CliXML Command PowerShell
export-clixml and compare-object question PowerShell
Export-Clixml output is inconvenient for viewing PowerShell
Export-CliXml/Export-Csv: Change to Export-Object? PowerShell