1.    10 Feb 2007 #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.    11 Feb 2007 #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


Similar Threads
Thread Forum
Export-clixml producing weird xml output
I have the following code: $regex = "(\d{3,4})" $query = Get-ChildItem -Recurse | Where-Object {$_.Name -match $regex} | ? {$_.psIsContainer} |...
PowerShell
Import-CliXml error
I'm trying to import an XML file to a variable, and I get the following error: % $client = import-clixml...
PowerShell
deserialize objects via import-clixml
Hi, I'm just doing my first steps in developing custom cmdlets. I have a first cmdlet which writes objects of type Document. So I have something...
PowerShell
Formatting Inline for Export-CliXML Command
Two things... First.. you dont want to use select.. use foreach-object $log | foreach-object{$_.Message -replace "'", ""} | export-clixml ...
PowerShell
export-clixml and compare-object question
I'm trying to compare a "living" object with one imported using import-clixml, but compare-object is not seeing them as identical. See code: PS...
PowerShell
Export-Clixml output is inconvenient for viewing
Export-Clixml writes all the data as the only line of text (well, except line breaks in the data). It is inconvenient for viewing of the output...
PowerShell
Export-CliXml/Export-Csv: Change to Export-Object?
I'd like to suggest that these two Export cmdlets (and their corresponding importers) be consolidated into Export-Object/Import-Object cmdlets. ...
PowerShell

Our Sites
  • Ten Forums
  • Eight Forums
  • Seven Forums
  • PC Help Forum
  • Help Me Bake
  • Site Links
  • Contact Us
  • Privacy and Cookies
  • About Us
    Windows Vista Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

    Designer Media Ltd
    All times are GMT -5. The time now is 14:02.
    .