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 dll_compare {
param($path1,$path2)
$first = Get-ChildItem -Path $path1 -Filter *.dll
$second = Get-ChildItem -Path $path2 -Filter *.dll
$diff = Compare-Object -ReferenceObject $first -DifferenceObject $second -Property Name, Length, LastWriteTime, VersionInfo -PassThru | Select Name, Length, LastWriteTime, sideindicator,@{n="VersionInfo";e= { $_.VersionInfo.Productversion }}
$diff
}