Skip to content

Compare-PSCustomObject

SYNOPSIS

Compare two PSCustomObjects and return the comparison.

SYNTAX

__AllParameterSets

Compare-PSCustomObject [-Right] <Object> -Left <Object> [-OnlyChanged] [<CommonParameters>]

ALIASES

This cmdlet has the following aliases, {{Insert list of aliases}}

DESCRIPTION

This function compares two PSCustomObjects and returns an overview of the differences. It can also filter to show only the properties that have changed.

EXAMPLES

EXAMPLE 1

Compare-PSCustomObject -Left $object1 -Right $object2 -OnlyChanged

EXAMPLE 2

$object1 = [PSCustomObject]@{ Name = 'Test' Value = 1 } $object2 = [PSCustomObject]@{ Name = 'Test' Value = 2 } $object1 | Compare-PSCustomObject $object2

Output:

Property Left Right Changed
-------- ---- ----- -------
Name     Test Test    False
Value    1    2        True

PARAMETERS

-Left

The left object to compare

Type: System.Object
DefaultValue: ''
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: (All)
  Position: Named
  IsRequired: true
  ValueFromPipeline: true
  ValueFromPipelineByPropertyName: false
  ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''

-OnlyChanged

Only show properties that have changed

Type: System.Management.Automation.SwitchParameter
DefaultValue: False
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: (All)
  Position: Named
  IsRequired: false
  ValueFromPipeline: false
  ValueFromPipelineByPropertyName: false
  ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''

-Right

The right object to compare

Type: System.Object
DefaultValue: ''
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: (All)
  Position: 0
  IsRequired: true
  ValueFromPipeline: false
  ValueFromPipelineByPropertyName: false
  ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

INPUTS

System.Object

{{ Fill in the Description }}

OUTPUTS

NOTES