Question

I have a script that I want to make automatically run every Monday and Thursday each week. I was curious how if it is possible to do this on PowerCLI or if I would have to create a .bat to accomplish this goal. I did some searching and learned that this piece of code was necessary in my script at the top of the line:

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}

What else would I need to get this code to run every Monday and Thursday?

Thanks!

EDIT: Where would I edit the task scheduler in order to allow this to run? I've provided an image of where I'm at (that and I'm also a visual person :P )

enter image description here

Was it helpful?

Solution

Why not just using the Task Scheduler of Windows to execute your script as:

powershell.exe -file yourscript.ps1

use powershell /? to kown more options

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top