Hello everyone - i'm getting below errors while running script to get newly added VMs across multiple vCenters. Am i missing anything? please advise.
Errors:
Get-VIEvent : 8/13/2020 10:19:17 AM Get-VIEvent Error in deserializing body of reply message for operation 'RetrieveProperties'.
At line:5 char:11
+ $events = Get-VIEvent -maxsamples 100000 -Start (Get-Date).AddDays(–1 ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Get-VIEvent], VimException
+ FullyQualifiedErrorId : Core_BaseCmdlet_UnknownError,VMware.VimAutomation.ViCore.Cmdlets.Commands.GetEvent
Get-VIEvent : 8/13/2020 10:19:24 AM Get-VIEvent Error in deserializing body of reply message for operation 'ReadPreviousEvents'.
At line:5 char:11
+ $events = Get-VIEvent -maxsamples 100000 -Start (Get-Date).AddDays(–1 ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Get-VIEvent], VimException
+ FullyQualifiedErrorId : Core_BaseCmdlet_UnknownError,VMware.VimAutomation.ViCore.Cmdlets.Commands.GetEvent
Script:
Import-Module VMware.VimAutomation.Core
Connect-VIServer vCenter
$eventCollection = @()
$events = Get-VIEvent -maxsamples 100000 -Start (Get-Date).AddDays(–10) | where {$_.Gettype().Name-eq "VmCreatedEvent" -or $_.Gettype().Name-eq "VmBeingClonedEvent" -or $_.Gettype().Name-eq "VmBeingDeployedEvent" }
foreach ($event in $events)
{
$csvline = "" | Select EventTime, UserName, Datacenter, Cluster, Host, VM, Dvs, Description, vcenter
$csvline.EventTime = $event.CreatedTime
$csvline.UserName = $event.UserName
$csvline.Datacenter = $event.Datacenter.Name
$csvline.Cluster = $event.ComputeResource.Name
$csvline.Host = $event.Host.Name
$csvline.VM = $event.VM.Name
$csvline.Dvs = $event.Dvs.Name
$csvline.Description = $event.FullFormattedMessage
$csvline.vcenter = $event.VC.Name
$eventCollection += $csvline
}
$eventCollection | Export-csv -NoTypeInformation E:\output_file.csv
Thanks in advance.
You seem to be still using an MSI based install.
Time to upgrade.
Find the instructions in Welcome PowerCLI to the PowerShell Gallery – Install Process Updates
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
This was a known issue.
Which PowerCLI and vSphere version are you using?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Please check information below:
PowerCLI:
PowerCLI Version
----------------
VMware PowerCLI 6.5 Release 1 build 4624819
---------------
Component Versions
---------------
VMware Cis Core PowerCLI Component 6.5 build 4624453
VMware VimAutomation Core PowerCLI Component 6.5 build 4624450
vSphere:
Version 6.7.0 Build15976728
You seem to be still using an MSI based install.
Time to upgrade.
Find the instructions in Welcome PowerCLI to the PowerShell Gallery – Install Process Updates
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks for your recommendation. Let me get powerCLI updated and let you know if the issue still persist. Thank you!!
Thanks LucD as always, i was able to upgrade powerCLI to latest version and error is gone
VMware community appreciate your help!!