我有一个脚本,我想让自动运行每周一和周四每周。我很好奇,如果可以在PowerCLI上做到这一点,或者我必须创建一个.bat来实现这个目标。我做了一些搜索,发现这段代码在我的脚本中的行首是必需的:
add-pssnapin VMware.VimAutomation.Core # <----------
$server = $args[0]
$date = get-date
new-snapshot -vm $server -name "Auto Created via Powershell" -description $date
get-snapshot -vm $server | sort -property created -desc | select -skip 6 | foreach-object{remove-snapshot $_ -confirm:$false}要让这段代码在每周一和周四运行,我还需要做些什么?
谢谢!
编辑:我应该在哪里编辑任务计划程序才能让它运行?我已经提供了我所在位置的图像(我也是一个可视化的人:P )

发布于 2012-07-13 01:37:19
为什么不直接使用Windows的Task Scheduler来执行你的脚本呢?
powershell.exe -file yourscript.ps1使用powershell /?了解更多选项
https://stackoverflow.com/questions/11455814
复制相似问题