VMware Cloud Community
SENNAF1
Enthusiast
Enthusiast

Need to find VMs Moved off host prior to being put in Maintenance Mode

I need to find what VMs were on a host prior to putting into maintenance mode.   I had an issue and want to know if it is related to a particular VM.

I figured using Get-VIevent to search the logs and show what was migrated off the host between 10:00 am and 11:00am on 1/1/1970.

I have this but am having trouble getting it to work.

Get-VM | Get-VIEvent –Start “3/10/2017 8:00 AM” –Finish “3/10/2017 9:00 AM” | Where {$_.Gettype().Name -eq "VmBeingMigratedEvent"}

Get-VM | Get-VIEvent –Start “3/10/2017 8:00 AM” –Finish “3/10/2017 9:00 AM” | Where {$_.Gettype().Name -eq "MigrationEvent"}

Get-VM | Get-VIEvent –Start “3/10/2017 8:00 AM” –Finish “3/10/2017 9:00 AM” | Where {$_.Gettype().Name -eq "MigrationEvent"}

I do not get errors it just returns to the prompt.

Any help will be appreciated.

0 Kudos
4 Replies
LucD
Leadership
Leadership

Try starting from the root folder.

Get-Folder Datacenters |

Get-VIEvent –Start “3/10/2017 8:00 AM” –Finish “3/10/2017 9:00 AM” |

Where {$_.Gettype().Name -eq "VmBeingMigratedEvent"}


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

0 Kudos
SENNAF1
Enthusiast
Enthusiast

Thanks for your help with this. But I still get no entrys

A picture is worth a 1000 words.  I had a host crash during patching and I want to know what guests were on it prior to the host going into maintenance mode.

Here is what the logs show I just want to get it via script.

Thanks,

Event.png

0 Kudos
LucD
Leadership
Leadership

There might be other events for vMotion if they are triggered by DRS, for example DrsVmMigratedEvent.

Can you have a look at the type of events you see for that timeslot (update the $start and $finish variables))?

This will not show the details for TaskEvent, EventEx nor ExtendedEvent entries, but it should give a view on what events were fired.

Get-VIEvent -Start $start -Finish $finish |

Group-Object -Property {$_.GetType().Name}


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

0 Kudos
Freep
Contributor
Contributor

If the host is part of DRS, the other two types it could be under are: "DrsVmMigratedEvent" or "VmMigratedEvent"

0 Kudos