I wrote a powershell script to compare the content of two folders:
$Dir1 ="d:\TEMP\Dir1"
$Dir2 ="d:\TEMP\Dir2"
function Test-Diff($Dir1, $Dir2) {
$fileList1 = Get-ChildItem $Dir1 -Recurse | Where-Object {!$_.PsIsContainer} | Get-Item |…
Quick Question
Is there a better (i.e. more efficient / more concise) way to do this?
compare-object $a $b | ?{$_.SideIndicator -eq '<='}
Detail
Compare-Object gives paramenters -excludeDifferent and -includeEqual to allow you to amend which…
Here is the script that I wrote:
function Compare {
$file1 = Read-Host "Please enter the path of the first file you would like to compare"
$file2 = Read-Host "Please enter the path of the second file you would like to compare"
$outFile…
So I'm playing around with Compare-Object, and it works fine for comparing files. But what about just strings? Is there a way to find the difference between strings? CompareTo() is good about reporting that there is a difference, but not what the…
Lets take an example you have two employee object having same values as follows.
Employee employee1 = new Employee(1001, "Sam", 20000);
Employee employee2 = new Employee(1001, "Sam", 20000);
if(doCompareEmployees(employee1, employee2)){
…
I have 2 CSV files with user names.
I want to export just the names of users who don't exist in both files.
The code I have now:
$file1 = import-csv -Path "C:\ps\output\adusers.csv"
$file2 = import-csv -Path "C:\ps\output\users.csv"
Compare-Object…
Problem
I have two CSV files, file A and file B. Both files contain the same header.
The files contain information about quotes and orders.
File A was created first, at let’s say 10:00 AM. File B was created at 11:00 AM. That’s when the status…
I've looked at numerous examples and have made headway in producing a change report. But, I'm stuck in one area. Here's the scenario...
File 1 CSV file sample data
ID,Name,Location,Gender
1,Peter,USA,Male
2,Paul,UK,Male
3,Mary,PI,Female
File 2 CSV…
I'm attempting to create a PowerShell script that will run once every morning (via Task Scheduler) and alert someone (via Direct Send (I know how to do this and will implement said feature later)) if a file wasn't created during each hour for the…
I would like to compare the version info of files from two different directories.
I could do this:
$files1 = (Get-Item "$path1\*.dll").VersionInfo
$files2 = (Get-Item "$path2\*.dll").VersionInfo
compare-object $files1 $files2
But then I get…
I have a CSV file which contains multiline in some cells. I will use this data to compare the value got it from powershell.
This returns differences between the object, however the value is the same.
Expected Results should return nothing because…
I want to compare 2 text files and output the difference in another text file.
$Location = "c:\temp\z.txt"
compare-object (get-content c:\temp\hostname_old.txt) (get-content c:\temp\hostname_new.txt) | format-list | Out-File…
Can I change the output for SideIndicators as a result of Compare-Object to something more user friendly for standard users?
I have a script that compares the folder of a 2017 version of our software and the current 2018 version.
$var1 =…
I am attempting to put the output of compare-object. I am new to Powershell and unfortunately don't know the ins and outs yet.
My command is as follows:
Compare-Object -referenceObject $(Get-Content "c:\temp\mek\123-first.txt") -differenceObject…
I am comparing dll files based on size, last write time and version number using Compare-object in Powershell. These files are stored on remote servers. I am getting the result. The only problem is how to get the value of the version number from the…