VMware Cloud Community
imcooltanmay
Enthusiast
Enthusiast
Jump to solution

Report VMs deleted past 90 days

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

1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

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.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

9 Replies
LucD
Leadership
Leadership
Jump to solution

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.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

imcooltanmay
Enthusiast
Enthusiast
Jump to solution

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

0 Kudos
LucD
Leadership
Leadership
Jump to solution

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


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
imcooltanmay
Enthusiast
Enthusiast
Jump to solution

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

0 Kudos
LucD
Leadership
Leadership
Jump to solution

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


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

imcooltanmay
Enthusiast
Enthusiast
Jump to solution

Thank you @LucD

0 Kudos
wotriga1
Contributor
Contributor
Jump to solution

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

0 Kudos
LucD
Leadership
Leadership
Jump to solution

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


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
wotriga1
Contributor
Contributor
Jump to solution

Yes Thank You that fixed it!
0 Kudos