Questions tagged [compareobject]

Usually refers to object comparison in object oriented languages.

Typical cases compare:

  • Ojects values.
  • Object references.
  • Object types.
99 questions
1
vote
1 answer

Compare-Object Dynamic Variables for ReferenceObject DifferenceObject

This Compare-Object doesn't work, but is there a way to do the same thing? For ($F=0; $F -le $NumberOfSameFolders; $F++) { $Results$F = Compare-Object "$FilesInFolderX$F" "$FilesInFolderY$F" -Property Name, LastWriteTime -IncludeEqual -PassThru |…
Cliff
  • 35
  • 6
1
vote
1 answer

Compare-Object Find Matches and Remove Found from First Object

I'm wondering if there's a simpler way to accomplish this. I have two (JSON) objects, where they have properties that are lists of IPs (the properties are individual IPs). I'm comparing the two object properties to find any matching items and want…
MrMr
  • 483
  • 1
  • 9
  • 25
1
vote
2 answers

Compare-object output in variable

I'm building a script that will compare the last octed of in-use IPv4 addreses, with all the available octeds (2 till 254). I am already this far that I do get a result by comparing array's, but my end-result is also an array, and I cannot seem to…
user5995822
1
vote
1 answer

Powershell script to recursively search and find file size differences

I have code that finds if a file/folder exists or not in a different location, basically compares two folders. I cannot seem to find anything online to also search file size differences. My code is below and I just need help on how to recursively…
user6124417
  • 69
  • 2
  • 9
1
vote
1 answer

Compare-Object Output Format

I have two CSV files I need to compare. Both of which may (or may not) contain an additional delimited field (delimited via a "|" character), like…
gravity
  • 2,175
  • 2
  • 26
  • 34
1
vote
1 answer

Fail to run Compare-Object in Windows 10

I´m trying to run Compare-Object for a mounted ISO. These 3 lines works perfect with v 4.0 in Windows 8.1. $Driveletters = (Get-Volume).Driveletter $SetupDriveLetter = (Mount-DiskImage -ImagePath "Mypath") $ISODriveletter = (Compare-Object…
1
vote
0 answers

Optimization of powershell script

I am comparing 2 DLL files based on name, size, last write time and version using the following script. These files are stored on a remote server. My script is working fine but it is taking too long. Is there a way to optimize my script? function…
Shelly Tomar
  • 185
  • 1
  • 10
1
vote
1 answer

Comparing files based on version number and some other criteria and Formatting the output

I am comparing 2 files based on size, last write time and version number using Compare-object in Powershell. I am getting the results. The only problem is how to get the value of the version number from the result. function dll_compare(){ …
Shelly Tomar
  • 185
  • 1
  • 10
1
vote
1 answer

Powershell Compare-Object pipe to file and function

I'm a Powershell rookie and I would like to pipe the result of Compare-Object to a Write-Progress function (progress bar) as well as a .csv file. I have the following, but it only writes to the file. Can I only use a single pipe? I have large…
user1172456
  • 153
  • 2
  • 9
1
vote
1 answer

Comparing Object, include Computername in output but do not use it

I want powershell to Compare a few XML files that contain services, status and computernames. That include all of these in the output but only use Name and Status for comparison. The Idea is to get an output like so: Name Status…
Just a user
  • 609
  • 2
  • 10
  • 19
1
vote
1 answer

Assert.Equal anonymous objects across assemblies fails

My Assert.Equal() for an anonymous object is returning false, however very carefully inspecting the properties by hand in the debugger everything seems fine. It doesn't complain about the properties per say, only the following (which if you compare…
Alex KeySmith
  • 16,657
  • 11
  • 74
  • 152
0
votes
1 answer

PowerShell Compare-Object (Inlcuding Equals)

I am trying to compare two objects in PS. $object1 = "1.1.1.1,2.2.2.2,3.3.3.3" $object2 = "3.3.3.3,4.4.4.4" How do I compare these two objects and include similarities into a new variable? I've tried - $compare = Compare-Object -IncludeEqual…
0
votes
2 answers

Compare-Object (powershell) : return a property but don't compare with it

I am using Compare-Object to compare 2 bidimensional arrays issued by Get-ChildItem. I am asking it to compare using the Name property using -Property 'Name' This returns a table with the Name property and SideIndicator. The problem is that I would…
Silloky
  • 147
  • 13
0
votes
1 answer

In Powershell, how do I split text from Compare-Object input and sort by one of the split values?

Here is a sample input from two different files hash1.txt and hash2.txt: hash1.txt: abcdef01234567890 \path\to\file1.txt 01234567890abcdef \path\to\file2.txt a0b1c2d3e4f567890 \path\to\file3.txt hash2.txt abcdef01234567890…
HTWingNut
  • 213
  • 1
  • 7
0
votes
1 answer

How do i export results of a foreach-object with custom object in powershell

I can't seems to be able to export the results of the Foreach in a csv or even a txt file. It asks me for input or simply a blank file What the code do is import two csv both with same values but with eventual difference or missing value compare…
Luchrmn
  • 3
  • 2