Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Powershell script to automatically delete Snapshots in VMWare

Posted on 2010-09-16
8
Medium Priority
?
1,844 Views
Last Modified: 2012-05-10
Hi there

I'm looking for a script that will delete the Snapshots on our VM machines..I've read somewhere that this can be done with powershell but not sure where to start looking etc

Many thanks
0
Comment
Question by:Colchester_Institute
[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
  • 5
  • 3
8 Comments
 
LVL 24

Accepted Solution

by:
Luciano Patrão earned 2000 total points
ID: 33691681
0
 
LVL 1

Author Comment

by:Colchester_Institute
ID: 33692355
The first link seems the best option as it also gives a link to another good site.

I dont know ESX or Peral (so script no use to me there)

and the last link is pretty much a good reference but couldnt find any info on scripting what i need (info was good mind you)

I guess i just need to work out how to get one of the two scripts on from the first link working?
0
 
LVL 24

Expert Comment

by:Luciano Patrão
ID: 33692457
Hi

Sorry i dont have much time right now, but you don need to know perl, the script is created, you just need to use perl script.pl and add the credentials from your vCenter or ESX host.

But latter on, i can take a look with more time, and give detail information

Sorry for now

Jail
0
Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

 
LVL 1

Author Comment

by:Colchester_Institute
ID: 33692592
Hi Bestway

No i can see the script is already there in Pearl, However I dont like using scripts of which i have no knowledge of,  I have some use of Powershell and so can follow most scripts and understand them, thats why i dont want to use the Pearl one.

I'm sure it possibly works fine for what i want but as a solution for me personally that option is a no no :-)

If you get the time to find your script (powershell?) then i'd appreciate it...cheers
0
 
LVL 24

Expert Comment

by:Luciano Patrão
ID: 33694291
hi

i will check script and test
Also i will try to find the script

Jail
0
 
LVL 24

Expert Comment

by:Luciano Patrão
ID: 33697287
Hi

I have change the script. I have tested and it works. This is a simple script, do not check the VM state before, etc., just check the VMs and snapshots and removed.

I can create a better one tomorrow.

Jail
$server = "servername"
$user = "user"
$pwd = "password"

Connect-VIServer $server -User $user -Password $pwd

$AllVirtualMachines = Get-VM

foreach ($VirtualMachine in $AllVirtualMachines)
	{$AllSnapshots=Get-Snapshot -VM $VirtualMachine
		foreach ($Snapshot in $AllSnapshots)
	 		{If ($Snapshot.ID -like "VirtualMachineSnapshot-*")
  			{Write-Host $VirtualMachine.Name, $Snapshot.Name, $Snapshot.Description
   	Remove-Snapshot -snapshot $Snapshot -RemoveChildren } } }

Open in new window

0
 
LVL 1

Author Comment

by:Colchester_Institute
ID: 33699739
Am i right in assuming that i need Power CLi installed
0
 
LVL 24

Assisted Solution

by:Luciano Patrão
Luciano Patrão earned 2000 total points
ID: 33699820
Hi

Yes this a power shell script

http://tinyurl.com/342een2

Jail
0

Featured Post

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

Question has a verified solution.

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

This article outlines why you need to choose a backup solution that protects your entire environment – including your VMware ESXi and Microsoft Hyper-V virtualization hosts – not just your virtual machines.
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
Teach the user how to use vSphere Update Manager to update the VMware Tools and virtual machine hardware version Open vSphere Client: Review manual processes for updating VMware Tools and virtual hardware versions: Create a new baseline group in vSp…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

610 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