You are here: > PowerShell > PowerShell 1.0 > Compare-Object
ActiveXperts Network Monitor 2015 proactively manages network servers, devices, databases and more.

Compare-Object - PowerShell 1.0

Microsoft Windows PowerShell is a command-line shell and scripting tool based on the Microsoft .NET Framework. It is designed for system administrators, engineers and developers to control and automate the administration of Windows and applications.

More than hundred command-line tools (so called "cmdlets") can be used to perform system administration tasks and Windows Management Instrumentation (WMI). These cmdlets are easy to use, with standard naming conventions and common parameters, and standard tools for piping, sorting, filtering, and formatting data and objects.


Back up your Hyper-V VMs Easy & Fast. 100% built for Hyper-V. Free for 2 VMs, forever.


-referenceObject PSObject[]
        Object(s) used as a reference for comparison.
    -differenceObject PSObject[]
        Object(s) to compare to the reference object(s).
    -syncWindow int
        Defines a search region where an attempt is made to re-sync the order if there is no match.
    -property Object[]
        Properties of the objects to compare.
        Make comparisons case-sensitive.
    -culture string
        The culture to use for comparisons.
        Display only the characteristics of compared objects that are equal.
        Displays characteristics of compared objects that are equal.
        By default only differences are displayed.
        Pass the object created by this cmdlet through the pipeline. 

        common parameters: -Verbose, -Debug, -ErrorAction, -ErrorVariable, -OutVariable.

Compare the content of two text files:

PS C:\>compare-object -referenceobject $(get-content C:\file1.txt) $(get-content C:\file2.txt)

Compare the processes running before and after starting a copy of notepad.exe, using Get-Process to retrieve the processes running and store them in a variable:

 PS C:\>$proc_before = get-process
 $proc_after = get-process
 compare-object -referenceobject $proc_before -differenceobject $proc_after