Windows Vista Forums
Vista Forums Home Join Vista Forums Donate Vista Tutorials Tags

Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Microsoft Technical Newsgroups > PowerShell

export-clixml and compare-object question

Update your Vista Drivers Update Your Drivers Now!!
Closed Thread
 
Thread Tools Display Modes
Old 12-20-2006   #1 (permalink)
Gaurhoth
Guest


 

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 ps:\> $g = gwmi -class win32_desktop
PS ps:\> export-clixml -path desktop.xml -input $g
PS ps:\> $h = import-clixml desktop.xml
PS ps:\>
PS ps:\> compare-object $g $h

InputObject SideIndicator
----------- -------------
@{__GENUS=2; __CLASS=Win32_Desktop; __SUPERCLA... =>
\\COMPUTERONE\root\cimv2:Win32_Desktop.Name="N... <=
@{__GENUS=2; __CLASS=Win32_Desktop; __SUPERCLA... =>
\\COMPUTERONE\root\cimv2:Win32_Desktop.Name="N... <=
@{__GENUS=2; __CLASS=Win32_Desktop; __SUPERCLA... =>
@{__GENUS=2; __CLASS=Win32_Desktop; __SUPERCLA... =>
@{__GENUS=2; __CLASS=Win32_Desktop; __SUPERCLA... =>
@{__GENUS=2; __CLASS=Win32_Desktop; __SUPERCLA... =>
@{__GENUS=2; __CLASS=Win32_Desktop; __SUPERCLA... =>
\\COMPUTERONE\root\cimv2:Win32_Desktop.Name="N... <=
\\COMPUTERONE\root\cimv2:Win32_Desktop.Name="c... <=
\\COMPUTERONE\root\cimv2:Win32_Desktop.Name="S... <=
\\COMPUTERONE\root\cimv2:Win32_Desktop.Name="S... <=
\\COMPUTERONE\root\cimv2:Win32_Desktop.Name=".... <=


My expectation was that Compare-Object would see the $g and $h as the same since $h is just the XML representation of $g written out with export-clixml and reimported with import-clixml. Am I missing something or my understanding of export/import-clixml totally off-base?

gaurhoth

My System SpecsSystem Spec
Old 12-21-2006   #2 (permalink)
/\\/\\o\\/\\/ [MVP]
Guest


 

Re: export-clixml and compare-object question

I did meet Gaurhoth on IRC (#PowerShell on freenode)
and answered it there, but the workaround to get all properties ( -property
parameter does not support wildcards ) might be usefull for more people,
so I repost it here :

<mow002> as one is seralized they are different

<mow002> PoSH>$g | gm
<mow002> TypeName:
System.Management.ManagementObject#root\cimv2\Win32_Desktop
<mow002> PoSH>$h | gm
<mow002> TypeName:
Deserialized.System.Management.ManagementObject#root\cimv2\Win32_Desktop

<mow002> I found this trick to do a check on all properties (-property does
not support wildcards)
<mow002> compare-object $g $h -prop ($g |% {"$($_.psbase.properties | select
name)"})

Greetings /\/\o\/\/

"Gaurhoth" <gaurhoth@live.com> wrote in message
news:%23m9%23Z8FJHHA.3668@TK2MSFTNGP02.phx.gbl...
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 ps:\> $g = gwmi -class win32_desktop
PS ps:\> export-clixml -path desktop.xml -input $g
PS ps:\> $h = import-clixml desktop.xml
PS ps:\>
PS ps:\> compare-object $g $h

InputObject SideIndicator
----------- -------------
@{__GENUS=2; __CLASS=Win32_Desktop; __SUPERCLA... =>
\\COMPUTERONE\root\cimv2:Win32_Desktop.Name="N... <=
@{__GENUS=2; __CLASS=Win32_Desktop; __SUPERCLA... =>
\\COMPUTERONE\root\cimv2:Win32_Desktop.Name="N... <=
@{__GENUS=2; __CLASS=Win32_Desktop; __SUPERCLA... =>
@{__GENUS=2; __CLASS=Win32_Desktop; __SUPERCLA... =>
@{__GENUS=2; __CLASS=Win32_Desktop; __SUPERCLA... =>
@{__GENUS=2; __CLASS=Win32_Desktop; __SUPERCLA... =>
@{__GENUS=2; __CLASS=Win32_Desktop; __SUPERCLA... =>
\\COMPUTERONE\root\cimv2:Win32_Desktop.Name="N... <=
\\COMPUTERONE\root\cimv2:Win32_Desktop.Name="c... <=
\\COMPUTERONE\root\cimv2:Win32_Desktop.Name="S... <=
\\COMPUTERONE\root\cimv2:Win32_Desktop.Name="S... <=
\\COMPUTERONE\root\cimv2:Win32_Desktop.Name=".... <=


My expectation was that Compare-Object would see the $g and $h as the same
since $h is just the XML representation of $g written out with export-clixml
and reimported with import-clixml. Am I missing something or my
understanding of export/import-clixml totally off-base?

gaurhoth

My System SpecsSystem Spec
Closed Thread

Thread Tools
Display Modes



Similar Threads
Thread Thread Starter Forum Replies Last Post
Formatting Inline for Export-CliXML Command Brandon Shell PowerShell 14 09-18-2007 10:56 PM
Export/Import-CliXml oddity Keith Hill PowerShell 1 02-11-2007 04:01 AM
Testing object arrays using Compare-Object and -contains Alex K. Angelopoulos [MVP] PowerShell 2 08-31-2006 05:57 PM
Export-CliXml/Export-Csv: Change to Export-Object? Alex K. Angelopoulos [MVP] PowerShell 3 06-04-2006 07:57 PM
Adding canonical aliases for Compare-Object, Measure-Object, New-Object Alex K. Angelopoulos [MVP] PowerShell 2 05-26-2006 07:58 AM


Vistax64.com is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media 2005-2008

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51