Solved

Setting up VMWare powercli task in schdeduled tasks

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

In this article, I will show you HOW TO: Perform a Physical to Virtual (P2V) Conversion the easy way from a computer backup (image).
In this article we will learn how to backup a VMware farm using Nakivo Backup & Replication. In this tutorial we will install the software on a Windows 2012 R2 Server.
Teach the user how to install ESXi 5.5 and configure the management network System Requirements: ESXi Installation:  Management Network Configuration: Management Network Testing:
Advanced tutorial on how to run the esxtop command to capture a batch file in csv format in order to export the file and use it for performance analysis. He demonstrates how to download the file using a vSphere web client (or vSphere client) and exp…

803 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