Author Posts

March 31, 2017 at 8:50 pm

I'm learning about and writing my first PowerShell program, where I compare folders and files on two drives to find differences based on name and date. I'm checking a library of folders and files for differences between shipping and beta versions of software to help focus testing.

If I find an "unpaired" folder, then I don't want to list both the folder and its files in my output of differences. In this case, it is enough to know that there is a difference at the folder level. I'm checking a library of folders and files between shipping and beta versions of software to help focus testing. In the folders, there are only files, not subfolders.

I don't know how to filter the duplicate information. In the final version of my PowerShell program, I'll write the results (full pathnames) to a file. Will I have more powerful filtering capabilities if I store the Get-ChildItem and Compare-Object results in files or arrays rather than variables?

This is a simplified program that I'm writing to test ideas for the final program:

I've included my console output and pointed out the extraneous information in a comment block following the test program.

Thanks for your help.

April 2, 2017 at 3:31 am

This will export full paths to a csv file.

# Get folders
$ship = Get-ChildItem "F:\Shipping" -Recurse
$test  = Get-ChildItem "C:\Testing" -Recurse

# Compare name and date then export paths
Compare-Object $ship $test -Property Name,
LastWriteTime -PassThru | Select-Object FullName |
Export-Csv .\compare.csv -NoTypeInformation