VMware Horizon Community
JEHa
Contributor
Contributor
Jump to solution

How can I pull "Machines (View Composer Details)" for a linked clone pool with Powercli?

Good morning,

     I have been digging for two weeks trying to figure out how to pull the information from VMware Horizon 7 Administrator > Catalog > Desktop Pools > *select a linked clone pool* > Inventory > Machines (View Composer Details) with Powercli.  Has anyone already done this?

Message was edited by: Jimmy Hardesty - Added a screenshot of the information i'm trying to find. I can get the Machine name, datastore and status without any issues, but can't see the image/pending image of each individual virtual machine. I've only been able to pull the image/snapshot set for the entire pool with powercli.

1 Solution

Accepted Solutions
techguy129
Expert
Expert
Jump to solution

Here is a query. I ran this with the latest powercli

###############################################

#Param

$PoolName = "NameOfPool"

$connectionServer = "NameofConnectionServer"

#Connect

Connect-HVServer $connectionServer

#setup Query

$ViewAPI = $global:DefaultHVServers.ExtensionData

$query_service = New-Object "Vmware.Hv.QueryServiceService"

#get Pool ID

$querypool = ""

$querypool = New-Object "Vmware.Hv.QueryDefinition"

$querypool.Filter = new-object VMware.Hv.QueryFilterEquals -property @{'memberName' = 'desktopSummaryData.name'; 'value' = $PoolName}

$querypool.queryEntityType = 'DesktopSummaryView'

$Pool = $query_service.QueryService_Query($ViewAPI,$querypool)

#Get Machines

$querymachines = ""

$querymachines = New-Object "Vmware.Hv.QueryDefinition"

$querymachines.Filter = new-object VMware.Hv.QueryFilterEquals -property @{'memberName' = 'base.desktop'; 'value' = $Pool.Results.Id}

$querymachines.queryEntityType = 'MachineSummaryView'

$Desktops = $query_service.QueryService_Query($ViewAPI,$querymachines)

#Print Information

$Desktops.Results | %{

$machineinfo = @()

$machineinfo += $_.base

$machineinfo += (($global:DefaultHVServers.extensiondata.Machine.Machine_GetInfos($_.Id)).ManagedMachineData).ViewComposerData

$machineinfo

}

#Disconnect

Disconnect-HVServer

View solution in original post

5 Replies
Magneet
Hot Shot
Hot Shot
Jump to solution

I have done part of this in the vCheck I am building for View. You actually need to use the View api's and you'll pull it off.

Building a Horizon View vCheck with those nice api’s (part 1 of ??) – Retouw.nl

techguy129
Expert
Expert
Jump to solution

Here is a query. I ran this with the latest powercli

###############################################

#Param

$PoolName = "NameOfPool"

$connectionServer = "NameofConnectionServer"

#Connect

Connect-HVServer $connectionServer

#setup Query

$ViewAPI = $global:DefaultHVServers.ExtensionData

$query_service = New-Object "Vmware.Hv.QueryServiceService"

#get Pool ID

$querypool = ""

$querypool = New-Object "Vmware.Hv.QueryDefinition"

$querypool.Filter = new-object VMware.Hv.QueryFilterEquals -property @{'memberName' = 'desktopSummaryData.name'; 'value' = $PoolName}

$querypool.queryEntityType = 'DesktopSummaryView'

$Pool = $query_service.QueryService_Query($ViewAPI,$querypool)

#Get Machines

$querymachines = ""

$querymachines = New-Object "Vmware.Hv.QueryDefinition"

$querymachines.Filter = new-object VMware.Hv.QueryFilterEquals -property @{'memberName' = 'base.desktop'; 'value' = $Pool.Results.Id}

$querymachines.queryEntityType = 'MachineSummaryView'

$Desktops = $query_service.QueryService_Query($ViewAPI,$querymachines)

#Print Information

$Desktops.Results | %{

$machineinfo = @()

$machineinfo += $_.base

$machineinfo += (($global:DefaultHVServers.extensiondata.Machine.Machine_GetInfos($_.Id)).ManagedMachineData).ViewComposerData

$machineinfo

}

#Disconnect

Disconnect-HVServer

JEHa
Contributor
Contributor
Jump to solution

Awesome, that is what I was looking for.  You wouldn't happen to know how to show only some of the fields in the results?  Out-gridview and format-table doesn't work.  Ultimately, I'd like to have it in a table format, if possible.

$machineinfo | format-table | select Name, User, BasicState, BaseImageSnapshotPath, LastMaeintenanceTime, Operation, OperationState, BaseImagePath


Reply
0 Kudos
techguy129
Expert
Expert
Jump to solution

You need to switch the select and format-table

$machineinfo | select Name, User, BasicState, BaseImageSnapshotPath, LastMaintenanceTime  , Operation, OperationState, BaseImagePath | ft

Reply
0 Kudos
dzak64
Enthusiast
Enthusiast
Jump to solution

Very nice script - it's all the information that I'm looking for - but I would like to run against all desktop pools.

I've tried to modify this script, but I've had no luck.

Anyone have an idea(s) how to do this?

Reply
0 Kudos