When I try to run the above script using $evtMgr=Get-ViewEVentManager
I am getting the following error:
Get-View View with Id
'EventManager-EventManager' was not found on the server(s).
At C:\Myscripts\vmfailedtopoweron.ps1:3 char:11
+ $evtMgr = Get-View EventManager
+ ~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (:) [Get-View], VimException
+ FullyQualifiedErrorId : Core_GetView_WriteNotFoundError,VMware.VimAutoma
tion.ViCore.Cmdlets.Commands.DotNetInterop.GetVIView
You cannot call a method on a null-valued expression.
At C:\Myscripts\vmfailedtopoweron.ps1:18 char:1
+ $evtMgr.PostEvent($event,$null)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
But when I try with
$si = Get-View ServiceInstance
$evtMgr = Get-View $si.Content.EventManager
I don't get any error but I don't see the event generated in the specified VM. Why is it so?
And how do i figure out how to compose the specific event that I want to create?