Get-task -id <someid> returns the task but also the errormessage.
PS C:\WINDOWS\system32> get-task -id Task-task-4725953
get-task : 28-01-2021 13:05:43 Get-Task Object reference not set to an instance of an object.
At line:1 char:1
+ get-task -id Task-task-4725953
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Get-Task], VimException
+ FullyQualifiedErrorId : Core_BaseCmdlet_UnknownError,VMware.VimAutomation.Common.Commands.Cmdlets.GetTask
Name State % Complete Start Time Finish Time
---- ----- ---------- ---------- -----------
RemoveSnapshot_Task Success 100 01:03:29 01:03:45
Using latest 12.1 powercli
I suspect you might be connected to more than 1 vSphere server.
The error might come from the vSphere server where this Task is not known.
Check what is in $global:defaultVIServers
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
No- we only have one vCenter.
Changing the statement to Get-task | where {$_.id -eq <taskname> } make it work without error
Can you stop/start your PowerShell session?
It might be a corruption in the PS session.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Oh, yes - I have seen that before - will check it later.
After at powershell restart problem solved - both methods works. Thanks for your assist.