Solved

Setting up VMWare powercli task in schdeduled tasks

Posted on 2012-04-05
5
383 Views
Last Modified: 2012-04-17
I'm new to the VMWare powercli and I'm having some trouble making sense of the proper method of setting up a task in the scheduler.  

What I need to do is setup a scheduled task that will revert a VM back to a snapshot each sunday.  I'm open to any suggestions on how to proceed.


I was able to make this work properly to revert the VM back to the proper snapshot.  How can I have this kicked off at a specific time and day of the week?

$snapshot = Get-Snapshot -VM vapptest -Name "clisnaptest"
Set-VM -VM vapptest -Snapshot $snapshot

Overall we will be rolling out a process that we will rollback several systems to a baseline GA build every sunday evening.  I want to have this scheduled so it happens automatically.
0
Comment
Question by:mcioffi209
  • 4
5 Comments
 
LVL 117

Accepted Solution

by:
Andrew Hancock (VMware vExpert / EE MVE) earned 500 total points
ID: 37812467
Have a look at this walkthrough which explains the steps

Running a PowerCLI Scheduled task
0
 

Author Comment

by:mcioffi209
ID: 37833730
Thanks, I have seen that walk through but I'm not comfortable with it yet.

I will have another go at it and see how it goes.  We have another project taking up lots of time as well.

I have not used this tool at all, it is new to me.
0
 

Author Comment

by:mcioffi209
ID: 37834370
Ok, getting much closer.
I have a couple of questions about the script itself.  Overall it is a pretty simple task, but I need to be able to respond to the prompts and I would like add the credential file instead of leaving my user name and password exposed in the script.  So I have the following points if you can help me out.

1. Add the credential file into this process
2. Allow execution of the script:
           I know that I can run Set-ExecutionPolicy RemoteSigned or Set-ExecutionPolicy Unrestricted but it prompts me for:
          [Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "Y"):
3. Same issue with my script below.  It will ask me for Y,A,N,L,S,?

How do I use the default or set the confirm to false?

connect-VIServer -Server VCAVCENTER -User domain\CIOFFI -Password password321
$snapshot = Get-Snapshot –VM vrefservername –Name ”vrefservername_base”
Set-VM –VM vrefservername –Snapshot $snapshot

I'm calling the script from the command line, the calling works fine but the script does not:

C:\WINDOWS\system32\windowspowershell\v1.0\powershell.exe -PSConsoleFile "C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\vim.psc1" "& 'C:\testing\revert_vrefservername_snap_.ps1'"

Thanks.
0
 

Author Comment

by:mcioffi209
ID: 37834640
I think I have the solution.

I will post after a couple of test runs.

Thanks.
0
 

Author Comment

by:mcioffi209
ID: 37857316
I have figured out what i needed.

By using a batch file and the task scheduler I was able to fully build out my solution.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

One of the new features of a version 7.0 or later virtual machine, supported in VMware vSphere 4.1, 5.0 or the VMware vSphere Hypervisor ESXi 4.1, ESXi 5.0 often overlooked by VMware Administrators is the ability to add and connect USB devices conne…
In this article, I will show you HOW TO: Create your first Windows Virtual Machine on a VMware vSphere Hypervisor 6.5 (ESXi 6.5) Host Server, the Windows OS we will install is Windows Server 2016.
Teach the user how to install vSphere Update Manager  Console to Windows system:  Install vSphere Update Manager: Configure vSphere Update Manager plug-in in vSphere Client: Verify vSphere Update Manager settings in vSphere Client:
Teach the user how to convert virtaul disk file formats and how to rename virtual machine files on datastores. Open vSphere Web Client: Review VM disk settings: Migrate VM to new datastore with a thick provisioned (lazy zeroed) disk format: Rename a…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now