• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Export/Import-CliXml oddity

K

Keith Hill

#1
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 Computer

R

RichS

#2
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 Computer

Users Who Are Viewing This Thread (Users: 1, Guests: 0)