Rovshan Musayev
Rovshan Musayev

Reputation: 144

Get-VIEvent for datastore

Is it possible to get events for particular datastore with Get-VIEvent PowerCLI command? If yes, the how? I have tried this option for virtual machines, it works:

Get-VIEvent -Entity 'vm_name' | Where-Object {($_.FullFormattedMessage -match '*') }

But it's not working for datastores and I am curious why?

Upvotes: 0

Views: 1650

Answers (1)

Kyle Ruddy
Kyle Ruddy

Reputation: 2121

As far as I can tell, the entity parameter is looking for an object of type 'VIObject' and datastore isn't being referenced as a type of 'VIObject': https://code.vmware.com/doc/preview?id=5975#/doc/Get-VIEvent.html

A workaround, Get-VIEvent does have a Ds property that you can reference. Example:


PS C:\Users\kruddy> Get-VIEvent | Where-Object {$_.Ds.Name -like 'esxinfs01'}


Datastore            : VMware.Vim.DatastoreEventArgument
Key                  : 207208
ChainId              : 207208
CreatedTime          : 12/18/2017 12:11:35 PM
UserName             :
Datacenter           : VMware.Vim.DatacenterEventArgument
ComputeResource      :
Host                 :
Vm                   :
Ds                   : VMware.Vim.DatastoreEventArgument
Net                  :
Dvs                  :
FullFormattedMessage : Reconfigured Storage I/O Control on datastore esxinfs01
ChangeTag            :



PS C:\Users\kruddy> Get-VIEvent | Where-Object {$_.Ds.Name -like 'esxinfs01'} | Select-Object FullFormattedMessage

FullFormattedMessage
--------------------
Reconfigured Storage I/O Control on datastore esxinfs01


PS C:\Users\kruddy>

Upvotes: 2

Related Questions