在Windows排程器中編輯動作:
 
程式或指令碼: powershell
新增引數: -ExecutionPolicy Bypass -File "C:\RmtRuntime\rmt_zip_daily.ps1"
 
image
 
 
這裡必須指定 -ExecutionPolicy Bypass 才可執行
 
以下為 rmt_zip_daily.ps1 的內容
--------------------------------------------
#REQUIRES -Version 2


$ZipDate = [DateTime]::Today.AddDays(-1).ToString("yyyy-MM-dd")

$SourceFile = "D:\TempRMT\Source2020\$ZipDate.zip"
if (Test-Path $SourceFile) {
  Remove-Item $SourceFile
}
7z a $SourceFile  "E:\RMT Processing\Source\$ZipDate"
copy $SourceFile  "\\NAS01\Temp\Backup\Google\RMT Processing\Source2020\$ZipDate.zip"



$Source20sFile = "D:\TempRMT\Source2020-20s\$ZipDate.zip"
if (Test-Path $Source20sFile) {
  Remove-Item $Source20sFile
}
7z a $Source20sFile "E:\RMT Processing\Source20s\$ZipDate"
copy $Source20sFile "\\NAS01\Temp\Backup\Google\RMT Processing\Source2020-20s\$ZipDate.zip"

arrow
arrow
    全站熱搜

    ghostyguo 發表在 痞客邦 留言(2) 人氣()