一个月只执行一次代码块- Powershell脚本



我有一个每天运行的.ps脚本文件作业(周末和节假日除外)。我有代码块应该在一个月只执行一次。因为它是一个日常工作,所以它应该执行每月的第一个工作日。其余的代码每天执行,但我自己的这一部分应该一个月执行一次。有什么办法,我可以保持如果条件在powershell脚本,它如何知道后一个月的变化????

需要输入。

$day = (get-date).day
$triggerday = 1 #if you want the script to execute on the 1st day of the month. "1" appears only once a month
if($triggerday -eq $day )
{
#Do something here
}

最新更新