Compares two sets of objects. (Compare-Object)

   

# NAME
Compare-Object

# SYNOPSIS
Compares two sets of objects.

# SYNTAX
Compare-Object [-ReferenceObject] <PSObject[]> [-DifferenceObject] <PSObject[]> [-CaseSensitive] [-Culture <string>] [-ExcludeDifferent] [-IncludeEqual] [-PassThru] [-Property <Object[]>] [-SyncWindow <int>] [<CommonParameters>]

# DESCRIPTION
The Compare-Object cmdlet compares two sets of objects. One set of objects is the Reference set, and the other set is the Difference set.

The result of the comparison indicates whether a property value appeared only in the object from the Reference set (indicated by the <= symbol), only in the object from the Difference set (indicated by the => symbol) or, if the IncludeEqual parameter is specified, in both objects (indicated by the == symbol).

# PARAMETERS
-CaseSensitive [<SwitchParameter>]
Indicates that comparisons should be case-sensitive.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

-Culture <string>
Specifies the culture to use for comparisons.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

-DifferenceObject <PSObject[]>
Specifies the objects that are compared to the reference objects.

Required? true
Position? 2
Default value
Accept pipeline input? true (ByValue)
Accept wildcard characters? false

-ExcludeDifferent [<SwitchParameter>]
Displays only the characteristics of compared objects that are equal.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

-IncludeEqual [<SwitchParameter>]
Displays characteristics of compared objects that are equal. By default, only characteristics that differ between the reference and difference objects are displayed.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

-PassThru [<SwitchParameter>]
Passes the objects that differed to the pipeline. By default, this cmdlet does not generate any output.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

-Property <Object[]>
Specifies the properties of the reference and difference objects to compare.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

-ReferenceObject <PSObject[]>
Objects used as a reference for comparison.

Required? true
Position? 1
Default value
Accept pipeline input? false
Accept wildcard characters? false

-SyncWindow <int>
Defines a search region in which an attempt is made to re-synchronize the order if there is no match. The default value is [Int32]::MaxValue.

Required? false
Position? named
Default value [Int32]::MaxValue
Accept pipeline input? false
Accept wildcard characters? false

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

# INPUTS
System.Management.Automation.PSObject
You can pipe a DifferenceObject object to Compare-Object.

# OUTPUTS
None, or the objects that are different
When you use the PassThru parameter, Compare-Object returns the objects that differed. Otherwise, this cmdlet does not generate any output.

# NOTES

# EXAMPLE 1

C:\PS>compare-object -referenceobject $(get-content C:\test\testfile1.txt) -differenceobject $(get-content C:\test\testfile2.txt)

# Description
-----------
This command compares the contents of two text files. It displays only the lines that appear in one file or in the other file, not lines that appear in both files.

# EXAMPLE 2

C:\PS>compare-object -referenceobject $(get-content C:\Test\testfile1.txt) -differenceobject $(get-content C:\Test\testfile2.txt) -includeequal

# Description
-----------
This command compares each line of content in two text files. It displays all lines of content from both files, indicating whether each line appears in only Textfile1.txt or Textfile2.txt or whether each line appears in both files.

# EXAMPLE 3

C:\PS>$processes_before = get-process

C:\PS> notepad

C:\PS> $processes_after = get-process

C:\PS> compare-object -referenceobject $processes_before -differenceobject $processes_after

# Description
-----------
These commands compare two sets of process objects.

The first command uses the Get-Process cmdlet to get the processes on the computer. It stores them in the $processes_before variable.

The second command starts Notepad.

The third command uses the Get-Process cmdlet again and stores the resulting processes in the $processes_after variable.

The fourth command uses the Compare-Object cmdlet to compare the two sets of process objects. It displaysthe differences between them, which include the new instance of Notepad.

RELATED LINKS
Online version: http://go.microsoft.com/fwlink/?LinkID=113286
Group-Object
Measure-Object
Sort-Object
ForEach-Object
New-Object
Select-Object
Tee-Object
Where-Object

C:\Windows>powershell get-help ConvertTo-Html -full

ColorConsole [Version 1.7.1000] PowerShell 2.0-Export
Microsoft Windows [Version 6.1.7600]
Copyright (c) 2014 Microsoft Corporation.

OS: Windows-10 / Windows-8.1 & 8 / Windows-7 & Vista / Windows Server 2008-2016
»»»» ColorConsole



 


... Home  
... Impressum
... ColorConsole

... CMD
... Netsh-XP
... Netsh-7
... Netsh-Vista
... Powershell









Download the Windows 7 Starter, Home (Basic Premium), Professional und Ultimate!

... facebook.de
0.046
Can I save the desktop icon layout in the company without Admin rights?  / Wo finde ich gute Prozessoren-Charts, um die CPU-s besser vergleichen zu können?  / Download Windows 7 Starter, Home (Basic Premium), Professional, Ultimate!  / Office 2010 direkte Download Links plus Testversionen!  / How can i transfer the folder from View-1 to View-2?  / Wie kann ich am Schnellsten den Programme-Ordner in Windows-8 (8.1, 10) öffnen, finden?  / Wie kann ich zwischen den Registerkarten (Tabs) im Win 8, 8.1 Internet Explorer Start-App, oder Metro-App wechseln?  / Wo finde ich Systemeigenschaften in Windows-7?  / Wie kann man die E-Mails vom Outlook-Express nach Live-Mail exportieren?  / Wie funktioniert die Windows-Aktivierung, worauf sollte ich achten?  / Unterstützt Windows-7 den Cool’n’Quiet Stromsparmodus der AMD-Prozessoren?  / Was ist eine Bootdiskete?  /