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 search and find file size differences as well.
$source = Get-ChildItem -Recurse -path "C:\Users\Cl\Desktop\Source"
$compare = Get-ChildItem -Recurse -path "C:\Users\Cl\Desktop\WMIS"
Compare-Object -ReferenceObject $source -DifferenceObject $compare -PassThru
答案 0 :(得分:0)
Use measure-object
to compare file sizes, then if you want to do something afterwards (like copy the updated one to the destination) store them in a variable and create if
statements accordingly. You can use get-member
to view the properties you can use. I think this gives you the sizes in bytes so divide the results by "1GB". Try something like this:
$source = gci "c:\users\c1\desktop\source" -recurse | Measure-Object -property length -sum
#$source = ($source.sum / 1GB)
$compare = gci "c:\users\c1\desktop\WMIS" -recurse | Measure-Object -property length -sum
#$compare= ($compare.sum / 1GB)