Dear LucD,
thanks for your great get-taskplus, it works well against virtual center,
but failed repeatedly against standalone host vSphere 6.5,
PowerCLI C:\> $si = Get-View ServiceInstance
PowerCLI C:\> $tskMgr = Get-View $si.Content.TaskManager
PowerCLI C:\> $filter = New-Object VMware.Vim.TaskFilterSpec
PowerCLI C:\> $tCollector = Get-View ($tskMgr.CreateCollectorForTasks($filter))
Exception calling "CreateCollectorForTasks" with "1" argument(s): "The operation is not supported on the object."
At line:1 char:1
+ $tCollector = Get-View ($tskMgr.CreateCollectorForTasks($filter))
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : VimException
PowerCLI C:\>
looks like $filter not correct? do you know how to fix it? thanks
What you are seeing there are the recent task.
$si = Get-View ServiceInstance
$taskMgr = Get-View -Id $si.Content.TaskManager
Get-View -Id $taskMgr.RecentTask
But those are limited in time.
What doesn't exist on a stand-alone ESXi node is a TaskHistoryCollector.
In the vCenter you can specify how long the system should keep Tasks and Events, and you can't do this on a standalone ESXi node.
The first one is accessible through the TaskHistoryCollector, the 2nd one is the RecentTask from above.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Are you referring this Get-TaskPlus?
If yes, you have to read in the complete function first.
Easiest is to place it in a .ps1 file, then execute the .ps1.
Once you have the function "known" to the PS engine, you can call the function.
See the Sample Usage section in that same post.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
yes , get-taskplus failed due to similar error, so I tried to custom $filter myself, sorry for any confusion
PowerCLI C:\> Get-TaskPlus
Exception calling "CreateCollectorForTasks" with "1" argument(s): "The operation is not supported on the object."
At line:155 char:7
+ $tCollector = Get-View ($tskMgr.CreateCollectorForTasks($filter ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : VimException
You cannot call a method on a null-valued expression.
At line:158 char:9
+ $tCollector.ResetCollector()
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
You cannot call a method on a null-valued expression.
At line:165 char:9
+ $tasks = $taskReadOp.Invoke($WindowSize)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
PowerCLI C:\>
I overlooked that you mentioned a standalone ESXi node.
Afaik the HistoryCollector is not supported on an ESXi node, only on a vCenter.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
thanks LucD, when logged into the standalone host ui and I can see its history tasks, so I am wondering maybe I did not use the api correctly?
What you are seeing there are the recent task.
$si = Get-View ServiceInstance
$taskMgr = Get-View -Id $si.Content.TaskManager
Get-View -Id $taskMgr.RecentTask
But those are limited in time.
What doesn't exist on a stand-alone ESXi node is a TaskHistoryCollector.
In the vCenter you can specify how long the system should keep Tasks and Events, and you can't do this on a standalone ESXi node.
The first one is accessible through the TaskHistoryCollector, the 2nd one is the RecentTask from above.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I see, thanks