out of this how to grep for a particular string. i know there is an option called "findstr" . can you please mention how to use this findstr option?
There's a few (dozen) different ways to tackle this in PowerShell. I hope these examples help:
PS > $a = Get-VIEvent
PS > $a | group { $_.GetType().BaseType }
Count Name Group
----- ---- -----
20 VimApi.AlarmEvent {13875, 13874, 13873, 13872, 13853, 13852, 13846, 13845, 13809...
8 VimApi.SessionEvent {13871, 13870, 13869, 13823, 13816, 13815, 13813, 13812}
65 VimApi.VmEvent {13868, 13867, 13866, 13865, 13864, 13863, 13862, 13861, 13860...
2 VimApi.HostEvent {13821, 13819}
3 VimApi.Event {13820, 13818, 13784}
1 VimApi.GeneralEvent {13817}
1 VimApi.CustomFieldDefE... {com.icomasoft.PowerScripter.script}
PS > $a | Where-Object { $_.key -eq 13875 }
source : VimApi.ManagedEntityEventArgument
entity : VimApi.ManagedEntityEventArgument
from : gray
to : green
alarm : VimApi.AlarmEventArgument
key : 13875
chainId : 13845
createdTime : 12/7/2008 11:17:27 AM
userName :
datacenter : VimApi.DatacenterEventArgument
computeResource : VimApi.ComputeResourceEventArgument
host : VimApi.HostEventArgument
vm : VimApi.VmEventArgument
fullFormattedMessage : Alarm Virtual Machine Memory Usage on openfiler changed from Gray to Green
dynamicType :
dynamicProperty :
PS > $a | ? { $_.fullFormattedMessage -match "memory" } | select -first 5 | ft key, full* -auto
key fullFormattedMessage
--- --------------------
13875 Alarm Virtual Machine Memory Usage on openfiler changed from Gray to Green
13873 Alarm Virtual Machine Memory Usage on vcenter.halr9000.com changed from Gray to Green
13853 Alarm Virtual Machine Memory Usage on vcenter.halr9000.com changed from Green to Gray
13846 Alarm Virtual Machine Memory Usage on openfiler changed from Green to Gray
13809 Alarm Virtual Machine Memory Usage on openfiler changed from Gray to Green
[PowerShell MVP|https://mvp.support.microsoft.com/profile=5547F213-A069-45F8-B5D1-17E5BD3F362F], VI Toolkit forum moderator
Author of the upcoming book: Managing VMware Infrastructure with PowerShell
Co-Host, PowerScripting Podcast (http://powerscripting.net)
Need general, non-VMware-related PowerShell Help? Try the forums at PowerShellCommunity.org