Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Setting up VMWare powercli task in schdeduled tasks

Posted on 2012-04-05
5
386 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 119

Accepted Solution

by:
Andrew Hancock (VMware vExpert / EE MVE^2) 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

Portable, direct connect server access

The ATEN CV211 connects a laptop directly to any server allowing you instant access to perform data maintenance and local operations, for quick troubleshooting, updating, service and repair.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In this article, I will show you HOW TO: Install VMware Tools for Windows on a VMware Windows virtual machine on a VMware vSphere Hypervisor 6.5 (ESXi 6.5) Host Server, using the VMware Host Client. The virtual machine has Windows Server 2016 instal…
In this article, I show you step by step with screenshots to assist you - HOW TO: Deploy and Install the VMware vCenter Server Appliance 6.5 (VCSA 6.5), with some helpful tips along the way.
Teach the user how to install ESXi 5.5 and configure the management network System Requirements: ESXi Installation:  Management Network Configuration: Management Network Testing:
This video shows you how easy it is to boot from ISO images for virtual machines with the ISO images stored on a local datastore on the ESXi host.

856 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