【发布时间】:2023-03-22 10:50:01
【问题描述】:
这是我发布的this question 的后续,但现在遇到了枚举某些对象上的事件的问题。例如,当我运行以下代码(或尝试我之前问题中的任何解决方案)以从数据存储或数据存储集群中获取事件时:
Get-VMFolder FOLDER_NAME -Type Datastore | Get-DatastoreCluster | Get-VIEvent
对于它尝试返回的每个事件,我都遇到了以下错误:
Events can be retrieved only for inventory objects. The entity of type
'VMware.VimAutomation.ViCore.Impl.V1.DatastoreManagement.VmfsDatastoreImpl' will be ignored.
这特别烦人,因为 cmdlet 清楚地 枚举了事件,因为它尝试返回的每个事件都会出现此错误。
当我使用accepted answer 中提到的Get-TaskPlus 函数时,我之前的问题会返回不同的类型转换错误:
Cannot process argument transformation on parameter 'Entity'. Cannot convert the "DATASTORE_CLUSTER_NAME" value of type "VMware.VimAutomation.ViCore.Impl.V1.DatastoreManagement.DatastoreClusterImpl" to type "VMware.VimAutomation.ViCore.Impl.V1.Inventory.InventoryItemImpl".
如果我删除函数定义中 $Entity 参数的类型约束,错误就会消失,但我也没有得到任何结果。
我并不是真的在这里寻找建议或工具,但如果 Get-VIEvent 通过 PowerCLI 查找有关非库存对象的事件,是否有解决方法或更细微的方法来使用 PowerCLI 检索此信息?
【问题讨论】:
标签: powershell powercli vcenter