VMware Cloud Community
mooreka
Contributor
Contributor
Jump to solution

Get-VIEvent to find vm name?

Hello There,

Is there a way to get the vm name from get-vievent?

I am trying to find all vm's created in the last day (easy) and then get-vm...basic idea...

Get-VIEvent -maxsamples 20000 -Start (Get-Date).AddDays(-1) | where {$_.Gettype().Name -eq "VmBeingDeployedEvent|VmCreatedEvent|VmRegisteredEvent|VmClonedEvent"} | select Username, CreatedTime, FullFormattedMessage |
%{ get-vm $vm}

Thanks for the help!

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

I didn't look closely at your Where-clause, it should be like the code above.

Please try it like that.


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

View solution in original post

0 Kudos
4 Replies
LucD
Leadership
Leadership
Jump to solution

If you only need the VM name, that property is present in the Event object that is returned by Get-VIEvent.

$eventTypes = "VmBeingDeployedEvent","VmCreatedEvent","VmRegisteredEvent","VmClonedEvent" 
Get-VIEvent
-maxsamples 20000 -Start (Get-Date).AddDays(-1) |
where {$eventTypes -contains $_.Gettype().Name} | select Username, CreatedTime, FullFormattedMessage,@{N="VM";E={$_.VM.Name}}


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

mooreka
Contributor
Contributor
Jump to solution

Thanks LucD for the quick reply and direction.

I just tried adding that and now I get no output.

Any ideas?

Thanks!

0 Kudos
LucD
Leadership
Leadership
Jump to solution

I didn't look closely at your Where-clause, it should be like the code above.

Please try it like that.


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

0 Kudos
mooreka
Contributor
Contributor
Jump to solution

beautiful.

thanks!

0 Kudos