compare-object left or right side only compare-object left or right side only powershell powershell

compare-object left or right side only


there is no option like that for that cmdlet, however you could create a filter (in your profile for example) and then use it to filter the result :something like

filter leftside{param(        [Parameter(Position=0, Mandatory=$true,ValueFromPipeline = $true)]        [ValidateNotNullOrEmpty()]        [PSCustomObject]        $obj    )    $obj|?{$_.sideindicator -eq '<='}}

usage

compare-object $a $b | leftside


You can also add -property SideIndicator and use an if statement for it.

$Missing = compare-object $Old $new -Property Name,SideIndicator     ForEach($Grp in $Missing) {          if($grp.sideindicator -eq "<=") {               # Do Something here          }     }