VMware Cloud Community
cosmoit
Contributor
Contributor
Jump to solution

insert vievent by ps1 script

Hello,

i'd like to know if it's possible write a virtual machine event by ps1 script.

then retrive this event with command Get-VIEvent -Entity (Get-VM -name $vm) -Types Error

thanks

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

You can use the LogUserEvent to create your own events.

Something like this

$eventMgr = Get-View EventManager
$vm = Get-VM MyVM

$eventMgr.LogUserEvent($vm.Extensiondata.MoRef,"A sample user event")

You can retrieve these events as follows

Get-VIEvent -MaxSamples 10 -Entity $vm | where{$_.GetType().Name -eq "GeneralUserEvent"}


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

View solution in original post

0 Kudos
2 Replies
LucD
Leadership
Leadership
Jump to solution

You can use the LogUserEvent to create your own events.

Something like this

$eventMgr = Get-View EventManager
$vm = Get-VM MyVM

$eventMgr.LogUserEvent($vm.Extensiondata.MoRef,"A sample user event")

You can retrieve these events as follows

Get-VIEvent -MaxSamples 10 -Entity $vm | where{$_.GetType().Name -eq "GeneralUserEvent"}


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

0 Kudos
cosmoit
Contributor
Contributor
Jump to solution

perfect!

thank you very much

0 Kudos