VMware Cloud Community
impranayk
Enthusiast
Enthusiast

Script to get user names who put the multiple ESXi hosts in maintenance mode

There are multiple ESXi hosts running in maintenance mode. I want to get the username who put these hosts in maintenance mode. Is there any script or command that I can use to fetch this information? 

@LucD 

 

 

-------------------------------------------------------------------------
Follow me @ www.vmwareinsight.com
Please consider marking this answer "correct" or "helpful" if you found it useful

Pranay Jha | Blog: http://vmwareinsight.com
vExpert 2016/2017, VCAP5-DCD/DCA, VCP5-DCV, VCA-Cloud, VCE-CIA, MCSE, MCITP
0 Kudos
1 Reply
ObjectifDubai
Enthusiast
Enthusiast

Hi,

you can use this PowerCli command after connecting to vcenter. 

 

 

 

Get-VMHost | where{$_.ConnectionState -eq "Maintenance"} | 
Get-VIEvent -Start 23/03/2022 | where{ $_.FullFormattedMessage -match "Task: Enter maintenance mode"} | 
select @{N='Server';E={$_.Host.NAME}},USERNAME,CreatedTime

Server          UserName      CreatedTime
------          --------      -----------
myvmhost1       myUser       23/03/2022 20:17:03

 

 

 

 

0 Kudos