I'm trying to compare several files using md5 hash with powershell 2.0. The code works, the problem is that it's to slow. It takes longer in step 3. It's about 500 files to compare. Can you see a way to get it faster, like, don't do the step 3 every time?write-host 1    $COMP_ORI=$LOCAL_HOME+\+$PROG+\+$COMPARE    $file_ori = Get-ChildItem -Path $COMP_ORI -namewrite-host 2    $COMP_DEST=\\+$HOSTIP[$i]+\+$PROG_PATH    $file_dest = Get-ChildItem -PATH $COMP_DEST -namewrite-host 3    for ($i=0; $i -lt $file_ori.Count; $i++) {write-host compare md5 $i    if ( Get-ChildItem -PATH $COMP_DEST -name -Include $file_ori[$i] ) {        $md5 = New-Object -TypeName system.Security.Cryptography.MD5CryptoServiceProviderwrite-host 4        $hash_ori = [System.BitConverter]::ToString($md5.ComputeHash([System.IO.File]::ReadAllBytes($COMP_ORI+\+$file_ori[$i])))write-host 5        $hash_dest = [System.BitConverter]::ToString($md5.ComputeHash([System.IO.File]::ReadAllBytes($COMP_DEST+\+$file_ori[$i])))write-host 6    if ($hash_ori -ne $hash_dest) {        $out=$file_ori[$i]        $out=$out+ IS DIFFERENT        output message_solo $out    }}}
powershell md5 compare too slow
time limit exceeded;powershell;checksum