?
Solved

Setting up VMWare powercli task in schdeduled tasks

Posted on 2012-04-05
5
Medium Priority
?
390 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
[X]
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
  • 4
5 Comments
 
LVL 122

Accepted Solution

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

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

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

HOW TO: Install and Configure VMware vSphere Hypervisor 6.5 (ESXi 6.5), Step by Step Tutorial with screenshots. From Download, Checking Media, to Completed Installation.
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.
This tutorial will walk an individual through the steps necessary to enable the VMware\Hyper-V licensed feature of Backup Exec 2012. In addition, how to add a VMware server and configure a backup job. The first step is to acquire the necessary licen…
This video shows you how to use a vSphere client to connect to your ESX host as the root user. Demonstrates the basic connection of bypassing certification set up. Demonstrates how to access the traditional view to begin managing your virtual mac…
Suggested Courses

800 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