Last active
August 16, 2021 12:51
-
-
Save 9to5IT/51d5b49a3d77360f0df7 to your computer and use it in GitHub Desktop.
PowerShell: Get list of unique vCenter Events
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#----------------------------------------------------------------------------- | |
# Import PowerCLI Module | |
#----------------------------------------------------------------------------- | |
Add-PSSnapin VMware.VimAutomation.Core | |
#----------------------------------------------------------------------------- | |
# Connect to vCenter Server | |
#----------------------------------------------------------------------------- | |
$Server = Read-Host 'Specify the vCenter Server or ESXi Host to connect to (IP or FQDN)?' | |
Connect-VMwareServer -VMServer $Server | |
#----------------------------------------------------------------------------- | |
# Get list of unique events over a period of time | |
#----------------------------------------------------------------------------- | |
$Events = Get-VIEvent -maxsamples 100000 -Start "01/08/2015" -Finish "05/08/2015" | |
$aResults = @() | |
ForEach($Item in $Events){ | |
$sEventType = $Item.GetType().Name | |
If($aResults.Count -ge 1){ | |
If(!($aResults.Contains($sEventType))){ | |
$aResults += $sEventType | |
} | |
}Else{ | |
$aResults += $sEventType | |
} | |
} | |
$aResults | Sort-Object |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment