Exporting vCenter events using PowerCLI
search cancel

Exporting vCenter events using PowerCLI

book

Article ID: 328221

calendar_today

Updated On:

Products

VMware vCenter Server

Issue/Introduction

This article provides steps to export events on vCenter Server to a text file using PowerCLI cmdlets.
 

Environment

VMware vCenter Server

VMware PowerCLI

Resolution

To export events on vCenter Server to a text file:

1. Install PowerCLI on your supported platform (Windows, Linux, MacOS) from the Powershell Gallery if it is not yet installed:

PS> Install-Module -Name VMware.PowerCLI

2. Change the security policy (if needed):

PS> Set-ExecutionPolicy RemoteSigned

3. Connect to FQDN or IP of the target vCenter Server:

PS> Connect-VIServer -Server <VC-FQDN or VC-IP> -User '[email protected]'

4. Specify the date range and get events (dates described below are just examples):

PS> Get-VIEvent -Start "2025/12/01 00:00:00" -Finish "2025/12/02 00:00:00" > events.txt
 (This collects all events on 01 Dec 2025 in your local timezone of your PowerShell client.)
or
PS> Get-VIEvent -Start "2025/12/01 00:00:00" -Finish "2025/12/02 00:00:00" | Sort-Object -Property CreatedTime > events-sorted.txt
  (This also sorted the events by the CreatedTime)

5. Disconnect:

PS> Disconnect-VIServer


The -Start and -Finish options are both required unless retrieving only the latest 100 events. The event type values (Type = "Information", "Warning", "Error", ...) will not appear in the output text file, so the FullFormattedMessage field must be read to determine the event severity. 

Additional Information