Hello,
Is it possible to see the current tasks of poolls and VMs in powercli in Horizon View?
Thank You
You should be able to get those via the Task_Get method on the Task service.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
sorry I do not understand, would you have an example? the get-task command is only for Vphere no?
LucD This is horizon specific task.
its shows pending horizon tasks, which is different then a vcenter task.
My apologize I thought that was different, what Lucd gave was for horizon.
I know, and I never mentioned Get-Task nor vSphere Tasks.
The Task_Get method is from the Horizon View API, it is obviously not referring to the the same as vSphere Tasks, which you can query with the Get-Task cmdlet.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Try this, I'm not sure its correct, but maybe someone can fix it
# Import the Horizon module
Import-Module VMware.VimAutomation.HorizonView
# Establish connection to Connection Server
$hvServer = Connect-HVServer -server $hzConn -User $hzUser -Password $hzPass -Domain $hzDomain
$ViewAPI = $hvServer.ExtensionData
$query_service = New-Object "Vmware.Hv.QueryServiceService"
$query = New-Object "Vmware.Hv.QueryDefinition"
$query.queryEntityType = 'TaskInfo'
$Tasks = $query_service.QueryService_Query($ViewAPI,$query)
just replace $hzConn $hzUser $hzPass $hzDomain
I'm assuming you want all the Tasks, and I'm not sure how task_get will help. That will help with a specific task, but not searching them. Looking at this for a refence
Horizon View API – Query Service - The SLOG – SimonLong/Blog
you are supposed to be able to use the query service to search for TaskInfo, which is what Task_Get returns. I can get the above code to work using the DesktopSummaryView object but not the TaskInfo one.
Actually I read this more, since I wanted similar information. Tasks in the API reference the cloudpod architecture. TaskInfo which is what Task_Get returns has a catagory Type, and the only catagory types are
"POD_FEDERATION_INITIALIZING" | A task performing PodFederation initialize operation |
"POD_FEDERATION_UNINITIALIZING" | A task performing PodFederation uninitialize operation |
"POD_FEDERATION_JOINING" | A task performing PodFederation join operation |
"POD_FEDERATION_UNJOINING" | A task performing PodFederation unjoin operation |
so Task_Get won't help in this case.
Try this, I think this gets you want you want,
# Import the Horizon module
Import-Module VMware.VimAutomation.HorizonView
# Establish connection to Connection Server
$hvServer = Connect-HVServer -server $hzConn -User $hzUser -Password $hzPass -Domain $hzDomain
$ViewAPI = $hvServer.ExtensionData
$query_service = New-Object "Vmware.Hv.QueryServiceService"
$query = New-Object "Vmware.Hv.QueryDefinition"
$query.queryEntityType = 'MachineSummaryView'
$machines = $query_service.QueryService_Query($ViewAPI,$query)
$machineInfos=$ViewAPI.Machine.Machine_GetInfos($machineIds)
foreach($machineInfo in $machineInfos)
{
if($machineInfo.ManagedMachineData.ViewComposerData.Operation -eq "PUSH_IMAGE")
{
Write-Host $machineInfo.Base.Name $machineInfo.ManagedMachineData.ViewComposerData.Operation $machineInfo.ManagedMachineData.ViewComposerData.OperationState $machineInfo.ManagedMachineData.ViewComposerData.BaseImagePath $machineInfo.ManagedMachineData.ViewComposerData.PendingBaseImageSnapshotPath
}
}
It shows the desktop name, the maintenance task, what the state is, and the pending parent image, and the pending snapshot. The ones I had returned where the only ones that where showing up as pending tasks in horizon.
Hello and thank you for your return.
I think that it exceeds my competence, I thought to find a command type Get-HVtask ..... But no
I will test your script thank you very much I come back to you after
I couldn't get this working. Here is my output.
Exception calling "Machine_GetInfos" with "1" argument(s): "ExceptionType : VMware.Hv.MethodFault
ErrorMessage : Request missing value for required parameter 'ids' to method 'Machine_GetInfos'"
At line:21 char:1
+ $machineInfos=$ViewAPI.Machine.Machine_GetInfos($machineIds)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : VimException
Its much easier indeed:
$machines = Get-HVMachine -PoolName "YourPoolName"
$machine.ManagedMachineData.ViewComposerData.Operation
$machine.ManagedMachineData.ViewComposerData.OperationState
$machine.ManagedMachineData.InMaintenanceMode
}
Should give you the necessary informations.
Thanks MartinE11. How would I accomplish this for Instant Clones? We aren't using a View Composer.
Unfortunately I do not have the Instant Clone Feature licensed, so i can't really test it. But it should work as follows:
$machines = Get-HVMachine -PoolName "YourPoolName"
$hvServer = Connect-HVServer -Server $connectionServerName -ErrorAction Stop
$services = $hvServer.ExtensionData
$desktop_helper = New-Object VMware.Hv.DesktopService
foreach($machine in $machines){
$desktopInfo = $desktop_helper.Desktop_Get($services,$machine.Base.Desktop)
$desktopInfo.AutomatedDesktopData.ProvisioningStatusData.InstantCloneProvisioningStatusData.Operation
$desktopInfo.AutomatedDesktopData.ProvisioningStatusData.InstantCloneProvisioningStatusData.instantClonePendingImageState
$desktopInfo.AutomatedDesktopData.ProvisioningStatusData.InstantCloneProvisioningStatusData.instantCloneCurrentImageState
}
If you need any other Info, have a look at the API: https://vdc-repo.vmware.com/vmwb-repository/dcr-public/e2e25628-4ed2-43fc-8bad-54fb86f3bb0f/8e4d2491...
This is EXACTLY what I was trying to accomplish. Thank you for all of your help!!
No problem, glad I could help you.
there's a query service that should be able to list all running tasks as well,
oh and I added the get-hvtask to my project for the module. New functions vmware.hv.helper · GitHub
Hi,
Thanks sjesse and MartinE11 for useful info and scripts.
But according to all available properties for MachineViewComposerData object there are still some missing data.
It is primary Date/Time of scheduled task.
Does anyone know where it is possible to find Date/Time of scheduled tasks?
Thanks,
Pavel
Got a little confused trying to follow this thread, but *I think* you were about to answer the question I have. I'm trying to list active tasks (as you pointed out in your screenshot) of all Horizon Pools.
We're using Horizon 7.11 & PowerCLI ver.
PowerCLI Version
----------------
VMware PowerCLI 11.5.0 build 14912921
---------------
Component Versions
---------------
VMware Common PowerCLI Component 11.5 build 14898112
VMware HorizonView PowerCLI Component 7.1.0 build 14653756
VMware Cis Core PowerCLI Component PowerCLI Component 11.5 build 14898113
VMware VimAutomation VICore Commands PowerCLI Component PowerCLI Component 11.5 build 14899560
Task_Get doesn't seem to work for me.