How can I get a list of events related to a particular VM using PowerCLI?

Problem:

How can I get a list of events related to a particular VM using PowerCLI?

Solution:

$fileName = "c:\temp\NameOfVM.csv"
$entity = Get-VM -Name NameOfVM
Get-VIEvent -Entity $entity -MaxSamples 1000 | Select CreatedTime,UserName,FullFormattedMessage | Export-Csv -Path $fileName -NoTypeInformation -UseCulture 

Leave a Reply

Your email address will not be published. Required fields are marked *