VMware Horizon Community
curtistcreps
Enthusiast
Enthusiast

Horizon PowerCLI filtering Session ID's

I've searched all over the place trying to figure out why this doesn't work correctly. I am trying to display the list of Session IDs associated with each user with the Vmware.Hv.Helper module in PowerCLI. Syntax:


$SessionSummaries = Get-HVLocalsession

ForEach($SessionSummary in $SessionSummaries)
{
$DesktopName= $sessionSummary.NamesData.DesktopName
$sessionID=$sessionSummary.ID
$MachineName=$SessionSummary.NamesData.MachineOrRDSServerDNS
$SessionUserName=$SessionSummary.NamesData.UserName -creplace '^[^\\]*\\', ''
Write-Host "$SessionUserName is logged into $MachineName, SessionID is $SessionId"
}

This is what it is returning: 

curtistcreps_0-1654604320535.png

Based off what I have above in $SessionID = $SessionSummary.ID, I would expect to see the actual string of the IDs like what you would return by running (Get-HVLocalSession).ID:

curtistcreps_1-1654604511076.png

 

Any idea what I'm missing? Seems that just printing the contents of the $SessionID variable returns the appropriate string that I am expecting, but the second it is fed to the array, it no longer works...

 

 

 

 

Reply
0 Kudos
1 Reply
curtistcreps
Enthusiast
Enthusiast

Jumped the gun too quick: 

 

Modified the Write-Host line from:

Write-Host "$SessionUserName is logged into $MachineName, SessionID is $SessionId"

To:

Write-Host "$SessionUserName is logged into $MachineName, SessionID is" $SessionId.Id

 

Worked like a charm!

 

Reply
0 Kudos