VMware Cloud Community
MRoushdy
Hot Shot
Hot Shot
Jump to solution

Get the history of deleted VMs - not working

Hello, When I run the following command with the that value of "10000".

Get-VIEvent -maxsamples 10000 -Start (Get-Date).AddDays(14) |where{$_.Gettype().Name-eq "VmRemovedEvent"} |Sort CreatedTime -Descending|Select CreatedTime, UserName,FullformattedMessage

I get the following error:

Get-VIEvent : 10/1/2018 12:00:15 PM     Get-VIEvent             Error in deserializing body of reply message for operation

'RetrieveProperties'.

At line:1 char:1

+ Get-VIEvent -maxsamples 10000 -Start (Get-Date).AddDays(–60) |where { ...

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : NotSpecified: (:) [Get-VIEvent], VimException

    + FullyQualifiedErrorId : Core_BaseCmdlet_UnknownError,VMware.VimAutomation.ViCore.Cmdlets.Commands.GetEvent

But if I reduce that value to less than "1000", the command works.

What am I supposed to do to get a long history of the deleted VMs? and I also need to exclude the service user account used bue Veeam for the SureBackup as the result will be flooded by thousands of irreverent results.

vEXPERT - VCAP-DCV - Blog: arabitnetwork.com | YouTube: youtube.com/c/MohamedRoushdy
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

That is a known bug which was fixed in PowerCLI 10.2.0.

Upgrade to 10.2.0


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

View solution in original post

Reply
0 Kudos
4 Replies
LucD
Leadership
Leadership
Jump to solution

That is a known bug which was fixed in PowerCLI 10.2.0.

Upgrade to 10.2.0


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

Reply
0 Kudos
MRoushdy
Hot Shot
Hot Shot
Jump to solution

and how to exclude a specific user please?

vEXPERT - VCAP-DCV - Blog: arabitnetwork.com | YouTube: youtube.com/c/MohamedRoushdy
Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

If you mean from the report, then you can add that condition to the Where-clause.

Something like this

Get-VIEvent -maxsamples ([int]::MaxValue) -Start (Get-Date).AddDays(–14) |

where{$_ -is [VMware.Vim.VmRemovedEvent] -and $_.UserName -ne 'MyUser'} |

Sort -Property CreatedTime -Descending|

Select CreatedTime,UserName,FullformattedMessage


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

MRoushdy
Hot Shot
Hot Shot
Jump to solution

Worked fine.

Thank you,

vEXPERT - VCAP-DCV - Blog: arabitnetwork.com | YouTube: youtube.com/c/MohamedRoushdy
Reply
0 Kudos