系统相关
首页 > 系统相关> > Powershell-获取最新文件

Powershell-获取最新文件

作者:互联网

 $from_path=@("E:\xx\","E:\aa\")
$to_path="\\xx\ss"

$Subject="DR backup to cq "
$MailTo="jinwei@126.com"


try {

    foreach($i in $from_path)
    {
        cd $i;
        cp (dir $i |where {$_.Name  -like "*.bak*"}|Sort-Object LastWriteTime -Descending).name[0]  $to_path

    }
    Send-MailMessage -From $MailTo  -To  $MailTo  -Subject $Subject   -SmtpServer xx   -Body  "update job start time sucessful!"   -Encoding utf7
}
catch{
    Send-MailMessage -From $MailTo  -To  $MailTo  -Subject $Subject   -SmtpServer xx   -Body  "FailedItem:$_.Exception.ItemName"   -Encoding utf7
}  

标签:MailTo,文件,MailMessage,Send,获取,xx,path,Powershell,Subject
来源: https://www.cnblogs.com/JinweiChang/p/15953574.html