PowerCLI:任务自动化

时间:2012-07-12 15:55:51

标签: powershell scripting vmware powercli

我有一个脚本,我希望每周一周一和周四自动运行。我很好奇如果可以在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)

enter image description here

1 个答案:

答案 0 :(得分:2)

为什么不使用Windows的Task Scheduler来执行脚本:

powershell.exe -file yourscript.ps1

使用powershell /?提供更多选择

相关问题