Hello,@LucD
I need to know via which hosts are in maintenance mode, when it was entered, and who did it.
Have a look at Re: Identify Users that Placed ESXi Hosts into Maintenance Mode
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I'm using this script you made ... it works great, but it doesn't bring the user who made the process. Can you edit this script to also show the user who put the host into maintenance mode?
Function VisualizaHostManutencao{
Get-VMHost | where{$_.ConnectionState -eq 'Maintenance'} | Select Name, @{N='Date';E={
Get-VIEvent -Entity $_ -MaxSamples ([int]::MaxValue) |
where{$_ -is [VMware.Vim.EnteredMaintenanceModeEvent]} |
Sort-Object -Property CreatedTime -Descending |
Select -First 1 -ExpandProperty CreatedTime
}}
}
-----------------------------
Example of above script result
Name Date
---- ----
host2 03/10/2019 14:39:23
host1 03/10/2019 14:39:23
Try like this
Select Name,
@{N='Date';E={
$script:maint = Get-VIEvent -Entity $_ -MaxSamples ([int]::MaxValue) |
where{$_ -is [VMware.Vim.EnteredMaintenanceModeEvent]} |
Sort-Object -Property CreatedTime -Descending |
Select -First 1
$script:maint.CreatedTime
}},
@{N='User';E={$script:maint.UserName}}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi, LucD
Look at the result. Don´t bring anything
Name Value
---- -----
E $script:maint.UserName
N User
Looks like you might have missed a comma at the end of a line somewhere
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks