Thank you for your guidance, and also some of your previous scripts for capturing the event type.
As noted before, and on other posts and sites, that there are a few types of events that have the deserialization issue.
And those event types are:
HostSpecificationRequireEvent
HostSubSpecificationUpdateEvent
And I used the script made by you to capture the Events was:
$eventMgr = Get-View EventManager
$events = foreach($event in $eventMgr.Description.EventInfo){
New-Object PSOBject -Property @{
Key = $event.Key
Category = $event.Category
EventTypeId = &{
If('ExtendedEvent','EventEx' -contains $event.Key){
$event.FullFormat.Split('|')[0]
}
else{ $null}}
Description = $event.Description
}
}
___________________________________________________________________________
From there I pushed each event into a loop and captured where the errors happened:
$servins= get-view serviceinstance
$evtmgr= get-view $servins.Content.EventManager
$longlisteventcapture = @()
$erroreventlist = @()
foreach($singleevent in ($events.key | Select -Unique)) {
## Clear Errors to capture only when error happens in loop instance ##
$error.clear()
$NewEventFilterSpec = New-Object VMware.Vim.EventFilterSpec
$NewEventFilterSpec.Type = "$singleevent"
[array]$newlistofevents = $evtmgr.QueryEvents($NewEventFilterSpec)
if ($error -ne $null) {Write-host "$singleevent error"; $erroreventlist += $singleevent}
Else {$longlisteventcapture += $newlistofevents}
}
_____________________________________________________________________________________
Now I have the workaround where I just avoid the 2 bad event types:
foreach($singleevent in ($events.key | Where {$_ -notlike "*HostSpecificationRequireEvent*" -and $_ -notlike "*HostSubSpecificationUpdateEvent*"} | Select -Unique)) {
$error.clear()
$NewEventFilterSpec = New-Object VMware.Vim.EventFilterSpec
$NewEventFilterSpec.Type = "$singleevent"
[array]$newlistofevents = $evtmgr.QueryEvents($NewEventFilterSpec)
if ($error -ne $null) {Write-host "$singleevent error"; $erroreventlist += $singleevent}
Else {$longlisteventcapture += $newlistofevents}
}
________________________________________________________________________________________
Its much slower and somewhat more resource intensive than Get-VIEvent, but it works for now
Again Thank you for your help