PowerCLI

 View Only
  • 1.  Report VMs deleted past 90 days

    Posted Jul 11, 2019 04:36 PM

    Is there a way to find deleted VM's from vcenter database?



  • 2.  RE: Report VMs deleted past 90 days
    Best Answer

    Posted Jul 11, 2019 04:47 PM

    Yes, provided you keep the events for that long.

    $start = (Get-Date).AddDays(-90)

    Get-VIEvent -Start $start -MaxSamples ([int]::MaxValue) |

    where{$_ -is [VMware.Vim.VmRemovedEvent]}

    ---------------------------------------------------------------------------------------------------------

    Was it helpful? Let us know by completing this short survey here.



  • 3.  RE: Report VMs deleted past 90 days

    Posted Jul 11, 2019 05:13 PM

    I tried to run above script it given below error. Get-VIEvent : 7/11/2019 12:09:32 PM Get-VIEvent Error in deserializing body of reply message for operation 'ReadPreviousEvents'. At line:4 char:1 + Get-VIEvent -Start $start -MaxSamples ([int]::MaxValue) | where{$_ -i ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~     + CategoryInfo          : NotSpecified: (:) [Get-VIEvent], VimException     + FullyQualifiedErrorId : Core_BaseCmdlet_UnknownError,VMware.VimAutomation.ViCore.Cmdlets.Commands.GetEvent



  • 4.  RE: Report VMs deleted past 90 days

    Posted Jul 11, 2019 05:14 PM

    That's a known issue in older PowerCLI versions.
    Update your PowerCLI version.



  • 5.  RE: Report VMs deleted past 90 days

    Posted Jul 12, 2019 12:57 PM

    I am using VMware PowerCLI 10.1.0 version. I believe it is updated version



  • 6.  RE: Report VMs deleted past 90 days

    Posted Jul 12, 2019 01:05 PM

    I'm afraid not, the 10.* versions is where this problem popped up.
    In the latest release 11.3, the issue is solved.



  • 7.  RE: Report VMs deleted past 90 days

    Posted Jul 12, 2019 01:16 PM

    Thank you @LucD



  • 8.  RE: Report VMs deleted past 90 days

    Posted Aug 12, 2019 08:46 PM

    I just upgraded to 11.3 and recieve this error:

    $ : The term '$' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the
    spelling of the name, or if a path was included, verify that the path is correct and try again.
    At line:1 char:1
    + $ start = ( Get-Date ).AddDays ( -30 ) | Get-VIEvent -Start $start -M ...
    + ~
        + CategoryInfo          : ObjectNotFound: ($:String) [], CommandNotFoundException
        + FullyQualifiedErrorId : CommandNotFoundException

    Thanks, I'm new to this
    Gary



  • 9.  RE: Report VMs deleted past 90 days

    Posted Aug 12, 2019 09:11 PM

    You seem to have a blank between the $ and the word 'start'



  • 10.  RE: Report VMs deleted past 90 days

    Posted Aug 12, 2019 09:41 PM
    Yes Thank You that fixed it!