Compare-Object and Export-Clixml



我想了解比较对象是如何工作的。我写了这个代码

PS> Get-Service -Name bits | Export-Clixml -Path .example.xml
PS> sleep 1
PS> Get-Service -Name bits | Export-Clixml -Path .example2.xml
> fc example.xml example2.xml
Comparing files example.xml and EXAMPLE2.XML
FC: no differences encountered
PS> sleep 1
PS> Compare-Object -ReferenceObject (Import-Clixml -Path .example.xml) -DifferenceObject (Get-Service -Name bits)

我:

InputObject SideIndicator
----------- -------------
bits        =>
bits        <=

但是我不明白为什么这两个物体不同。我尝试多次执行导出命令,看看xml中是否有与时间相关的参数。但是没有!

那么,错误在哪里?

Rr

感谢@mclayton,我认为以这种方式使用比较对象是不可能的

> Get-Service -Name bits | Get-Member             
TypeName: System.ServiceProcess.ServiceController
> Import-Clixml -Path .example.xml | Get-Member
TypeName: Deserialized.System.Service.ServiceController#StartupType

这是两个不同的类。

Rr

最新更新