2 Replies Latest reply on May 25, 2018 1:40 AM by Marco_2_G

    Removing snapshots found with get-view

    Marco_2_G Novice

      Hello!

       

      I have already posted another question here, so if you need some backgroundinfo...

       

      Anyway, I have gathered a list of vms that need their snapshots removed. I would like to do this with get-view since I seem to be getting a lot of errors of this kind:

       

      Get-VIObjectByVIView : 25.05.2018 09:52:05    Get-VIObjectByVIView        The object has already been deleted or has not been completely created

       

      When I try to convert it to an object.

       

      An example of the command I use is this:

       

      (Get-View -ViewType VirtualMachine -Filter @{"Summary.VM"=".*vm-1925199"}).rootsnapshot | Get-VIObjectByVIView

       

      So the idea was to use a method in get-view directly, however the method RemoveAllSnapshots I have found mentioned on the internet is not available anymore.

       

      So is there still a way to invoke a Delete All Snapshots from get-view?

        • 1. Re: Removing snapshots found with get-view
          LucD Guru
          Community WarriorsUser ModeratorsvExpert

          Sure there is, try like this.

          The $true parameter tells the system to consolidate after the removal.

          There is no need to have the '.*' in the RegEx expression.

           

          $vm = Get-View -ViewType VirtualMachine -Filter @{'Summary.VM' ='vm-1925199'}

          $vm.RemoveAllSnapshots($true)

           

          Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
          • 2. Re: Removing snapshots found with get-view
            Marco_2_G Novice

            Well, now I feel silly. I was looking through the methods of individual snapshots but it makes much more sense to have that function on the VM layer.

             

            Sorry for the stupid question and thank you once more for your help!