Hello.
I have tried to compare two ArrayList objects which contain custom PsObjects (TCP connections) inside.
So, I have the $ArrList1 object, which has the next TCP connections:
PS D:\WindowsPowerShell\Scripts> $ArrList1 | where {$_.ProcessName -eq 'icq'} LocalAddress : 0.0.0.0 LocalPort : 63857 RemoteAdderss : 0.0.0.0 RemotePort : 0 State : Bound AppliedSetting : PID : 12268 CreationTime : 25.07.2019 22:43:57 ProcessName : icq ProcessPath : C:\Users\tempuser\AppData\Roaming\ICQ\bin\icq.exe LocalAddress : 0.0.0.0 LocalPort : 63856 RemoteAdderss : 0.0.0.0 RemotePort : 0 State : Bound AppliedSetting : PID : 12268 CreationTime : 25.07.2019 22:43:55 ProcessName : icq ProcessPath : C:\Users\tempuser\AppData\Roaming\ICQ\bin\icq.exe LocalAddress : 0.0.0.0 LocalPort : 63855 RemoteAdderss : 0.0.0.0 RemotePort : 0 State : Bound AppliedSetting : PID : 12268 CreationTime : 25.07.2019 22:43:49 ProcessName : icq ProcessPath : C:\Users\tempuser\AppData\Roaming\ICQ\bin\icq.exe LocalAddress : 0.0.0.0 LocalPort : 63854 RemoteAdderss : 0.0.0.0 RemotePort : 0 State : Bound AppliedSetting : PID : 12268 CreationTime : 25.07.2019 22:43:49 ProcessName : icq ProcessPath : C:\Users\tempuser\AppData\Roaming\ICQ\bin\icq.exe LocalAddress : 127.0.0.1 LocalPort : 63845 RemoteAdderss : 127.0.0.1 RemotePort : 63846 State : Established AppliedSetting : Internet PID : 12268 CreationTime : 25.07.2019 22:43:46 ProcessName : icq ProcessPath : C:\Users\tempuser\AppData\Roaming\ICQ\bin\icq.exe LocalAddress : 192.168.1.2 LocalPort : 63844 RemoteAdderss : 178.237.20.123 RemotePort : 443 State : Established AppliedSetting : Internet PID : 12268 CreationTime : 25.07.2019 22:43:46 ProcessName : icq ProcessPath : C:\Users\tempuser\AppData\Roaming\ICQ\bin\icq.exe
When I have tried to kill icq.exe (and to close all connections of this process) and to make the new ArrayList object after this - $ArrList2, I have got the next result:
PS D:\WindowsPowerShell\Scripts> $ArrList2 | where {$_.ProcessName -eq 'icq'} | ft -AutoSize
no 'icq.exe' process connections.
When I have tried to compare these objects: Compare-Object -ReferenceObject $ArrList1 -DifferenceObject $ArrList2 -PassThru - I couldn't found any 'icq' processes in result with SideIndicator '<='.
Why have I this behavior ? I think that all 'icq' processes (which connections was closed) should be in 'ReferenceObject' and should be shown with '<=' SideIndicator. Am I right ?