【发布时间】:2021-10-24 23:42:08
【问题描述】:
我们在我们的环境中使用 vSphere 6.7。
我正在编写一个脚本来查找与我们的 vCenter 环境中的特定目标资源相关联的某些任务。但是,Get-Task 仅返回显示在 HTML5 客户端的 Recent Tasks 视图中的最近任务。我可以很好地获取与资源关联的事件,例如,我可以获取与给定数据存储文件夹关联的事件,如下所示:
Get-Folder FOLDER_NAME -Type Datastore | Get-VIEvent
但似乎没有等效的方法来获取与这些相同资源相关联的任务。 Get-Task 不像 Get-VIEvent 那样接受管道输入,并导致错误:
Get-Folder FOLDER_NAME -Type Datastore | Get-Task
输出:
Get-Task: The input object cannot be bound to any parameters for the command either
because the command does not take pipeline input or the input and its properties
do not match any of the parameters that take pipeline input.
Get-Task 也不显示任何未在 HTML5 客户端的 Recent Tasks 视图中显示的任务。
检查对象似乎没有提供任何成员让我看到针对这些资源的任务:
Get-Folder FOLDER_NAME -Type Datastore | Get-Member
输出:
TypeName: VMware.VimAutomation.ViCore.Impl.V1.DatastoreManagement.DatastoreClusterImpl
Name MemberType Definition
---- ---------- ----------
ConvertToVersion Method T VersionedObjectInterop.ConvertToVersion[T]()
Equals Method bool Equals(System.Object obj)
GetClient Method VMware.VimAutomation.ViCore.Interop.V1.VIAutomation VIObjectCoreInterop.GetClient()
GetHashCode Method int GetHashCode()
GetType Method type GetType()
IsConvertableTo Method bool VersionedObjectInterop.IsConvertableTo(type type)
LockUpdates Method void ExtensionData.LockUpdates()
ToString Method string ToString()
UnlockUpdates Method void ExtensionData.UnlockUpdates()
CapacityGB Property decimal CapacityGB {get;}
ExtensionData Property System.Object ExtensionData {get;}
FreeSpaceGB Property decimal FreeSpaceGB {get;}
Id Property string Id {get;}
IOLatencyThresholdMillisecond Property System.Nullable[int] IOLatencyThresholdMillisecond {get;}
IOLoadBalanceEnabled Property bool IOLoadBalanceEnabled {get;}
Name Property string Name {get;}
SdrsAutomationLevel Property VMware.VimAutomation.ViCore.Types.V1.Cluster.DrsAutomationLevel SdrsAutomationLevel {get;}
SpaceUtilizationThresholdPercent Property System.Nullable[int] SpaceUtilizationThresholdPercent {get;}
Uid Property string Uid {get;}
这不仅适用于文件夹任务,但如果它们不在 HTML5 的 Recent Tasks 视图中,我似乎根本无法枚举给定资源的 任何 任务客户。相反,在 HTML5 客户端中,我可以使用其Monitor 选项卡轻松枚举给定资源上的任务,但这无助于自动化,除非以编程方式爬过 UI(不会发生):
如何使用 PowerCLI 来查看使用 PowerCLI 以特定资源为目标的任务?
【问题讨论】:
标签: powershell powercli vcenter