使用命令:certutil -hashfile C:\XJ-Windows.csv MD5 ,再截取MD5值,最后进行比对
# MD5值较验
$temp1=certutil -hashfile C:\XJ-Windows.csv MD5
$temp1=$temp1 -split '\n'
$temp1=$temp1[1]
$temp2=certutil -hashfile C:\XJ-Windows-down.csv MD5
$temp2=$temp2 -split '\n'
$temp2=$temp2[1]
if ("$temp1" -eq "$temp2"){echo "文件校验成功"}else{echo "文件校验失败"}
echo $temp1," ",$temp2
使用内容比对(只适合内容不多的文件)
# 文件内容校验
$f1=(Get-Content C:\XJ-Windows.csv)[0..100]
$f2=(Get-Content C:\XJ-Windows-down.csv)[0..100]
if ("$f1" -eq "$f2"){echo "文件内容比对成攻"}else{echo "文件内容比对失败"}