VMware Cloud Community
OwenW201110141
Contributor
Contributor

Track VMs recently removed from inventory

Hi there,

Is there a cmdlet (or another method...) of determining the names of virtual machines that were recently removed from the inventory, and the date and time that they were removed?

Would be handy for keeping track of vms that go "missing".

Thanks,

Owen

Reply
0 Kudos
2 Replies
LucD
Leadership
Leadership

Sure, something like this will do the trick.

It uses the Get-VIEvent cmdlet.

And the Where-clause is used to filter out the events we're after.

$start = (Get-Date).AddMinutes(-10)

Get-VIEvent -Start $start | 
where
{$_ -is [vmware.Vim.VmRemovedEvent]} |
Select
@{N="VM";E={$_.Vm.Name}},CreatedTime,UserName,FullFormattedMessage

You can adjust the Start parameter to go further back in time.


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

OwenW201110141
Contributor
Contributor

Thanks a million Luc! Much appreciated!

Sent from my iPhone

Reply
0 Kudos