I am trying to find a means of listing all the View sessions, not the vCenter sessions, the user sessions of all users connected to a View guest, their user ID, their hostname, and other information. I can't find anywhere in the powershell documentation where I would do this. Does anyone know where to look? This is for VMWare 6.x.
Try something like this
$query = New-Object "Vmware.Hv.QueryDefinition"
$query.queryEntityType = 'SessionLocalSummaryView'
$qSrv = New-Object "Vmware.Hv.QueryServiceService"
$qSRv.QueryService_Query($global:DefaultHVServers[0].ExtensionData,$query) |
Select -ExpandProperty Results |
Select -ExpandProperty NamesData |
Select-Object -Property UserName,DesktopType,DesktopName,MachineOrRDSServerDNS
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Try something like this
$query = New-Object "Vmware.Hv.QueryDefinition"
$query.queryEntityType = 'SessionLocalSummaryView'
$qSrv = New-Object "Vmware.Hv.QueryServiceService"
$qSRv.QueryService_Query($global:DefaultHVServers[0].ExtensionData,$query) |
Select -ExpandProperty Results |
Select -ExpandProperty NamesData |
Select-Object -Property UserName,DesktopType,DesktopName,MachineOrRDSServerDNS
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
This gets the error straight out the gate "Cannot find type [Vmware.Hv.QueryDefinition]: verify that the assembly containing this type is loaded."
Not sure what I'm missing exactly.
Did you import the Horizon View module?
Import-Module -Name VMware.VimAutomation.HorizonView
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks, that last line says cannot index into a null array. Trying to figure it out at the moment. This is a completely new branch of Powershell for me.
Is $qSRv.QueryService_Query($global:DefaultHVServers[0].ExtensionData,$query) returning anything?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Nothing, that's the problem line, not sure why it isn't returning anything. I am suspecting it has more to do with needing a vCenter connection first?
Tried setting up a connection in the script, that did nothing to solve the error though but the connection works.
I tried adding this further up:
$ViewAPI = $global:DefaultHVServers[0].ExtensionData
Then tried using that variable the same way, but it said object not set to instance, meaning it's null. Weird. Why is that null?
Pretty much stuck here since there is literally nothing out there about this $global:DefaultHVServers[0].ExtensionData and it resulting in a null value.
You did do a Connect-HVServer before?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I had no idea about that command. I did Connect-VIServer.
You need to do that, the script uses $global:DefaultHVServers[0] , which get filled in after the Connect-HVServer
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Makes sense, it's like I run into one thing after another: "connect-hvserver : The remote server returned an unexpected response: (400) Bad Request"
I'm using:
connect-hvserver -Server servername -Domain domainname -User username -Password password
I look up this error but it's like nobody has ever talked about this online until now.
Try adding the -Verbose switch, see if that provides any additional information.
Can you try the Connect-HVServer with just the Server parameter, the cmdlet should prompt you for the missing parameters.
Does the hostname you pass on the Server parameter resolve correctly (do a nslookup)?
And you are trying to connect to a Horizon View Connection Server?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I assume I'm supposed to connect to the vcenter server where we manage the View environment?
If you want to retrieve further info from the VM, yes.
When you're only querying the Horizon environment, the Connect-HVServer should be enough.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I'm not connecting from a view associated VM though. Not sure how it would know where the view environment is. I'm trying to run this command on a Windows 2012 R2 server since that is how I want it to run in the end once I figure all this out.
Verbose is giving me no additional info. This is strange. Not sure why there isn't more documentation on this or if there is, I can't find it with Google.
When you do the Connect-HVServer the Server parameter specifies to which Connection Server.
And you don't need to be on a View desktop, just a desktop where you have PowerCLI installed.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference