cbadman
Contributor
Contributor

PowerCLI 6.5 Release 1 and get-remotesessions

Hello:

I am testing out VMware PowerCLI 6.5 Release 1 on a new server
Everything seems to be working out except for one cmdlet that we are using in our scripts.

I understand that The Get-remotesession cmdlet was present in the old View module (and only works with powershell 2.0) and on the CS server only.

My question is there any similar cmdlet in 6.5.1?
Our current scripts queries the duration of a remote session.

PS C:\Users\administrator.VLAB> Get-RemoteSession


session          : 0
Username         : xxxx
pool_id          : xxxx
startTime        : Thu Feb 15 08:12:15 PST 2018
session_id       : xxxx
DNSName          : xxxx
duration         : 22 minutes
lastSessionTicks : -1223468
state            : CONNECTED
protocol         : BLAST

BTW, is there page that has a list of arguments that you can pass the VMware.HV.Helper cmdlets?

Thanks,
Chris

Hello:
 
I am testing out VMware PowerCLI 6.5 Release 1 on a new server
Everything seems to be working out except for one cmdlet that we are using in our scripts.
 
I understand that The Get-remotesession cmdlet was present in the old View module (and only works with powershell 2.0) and on the CS server only.
 
My question is there any similar cmdlet in 6.5.1?
Our current scripts queries the duration of a remote session.
 
PS C:\Users\administrator.VLAB> Get-RemoteSession
0 Kudos
17 Replies
LucD
Leadership
Leadership

0 Kudos
cbadman
Contributor
Contributor

Thanks.

I checked the script and the main cmdlet is Get-HVMachineSummary which works and gives a list of all sessions but I need more details specially on how long the machine has been connected.
Perhaps, I can rephrase my question, is there a way to get the the session duration of a connected machine?

0 Kudos
LucD
Leadership
Leadership

That info is not readily available through any of the functions in the HVHelper module afaik.

But you can use the QueryService_Query to get to the SessionGlobalSummaryView which contains the SessionData object with that info.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
cbadman
Contributor
Contributor

Thanks,
SessionData looks promising, it does not have the session duration but it does have startTime
I'll check this out

By the way, is there a man page for all the new VMware.HV
I'm very new to this and wondered which parameters or arguments that I can pass the cmdlets

Best,
Chris

0 Kudos
LucD
Leadership
Leadership

There aren't many cmdlets available for Horizon as you will soon discover.

Most of the functionality is offered through the VMware.Hv.Helper module, which is open sourced.

In there you'll find many examples of how to use the Horizon View Services

Ray did a great intro in Quick Guide to the Horizon 7 API with VMware PowerCLI
And then there is Wouter's website with quite some interesting scripts and snippets.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
Magneet
Hot Shot
Hot Shot

+ just ask me and I will see if I or someone else can add the cmdlet Smiley Happy

0 Kudos
cbadman
Contributor
Contributor

Hi Magneet:

If someone can create the cmdlet.  That would be great.

Thank you so much,

Chris

0 Kudos
Magneet
Hot Shot
Hot Shot

check the github, it has get-hvlocalsession and get-hvglobalsession since some weeks Smiley Happy

0 Kudos
cbadman
Contributor
Contributor

Hi Magneet:

we are finally getting done with the semester, so now I can work on this again.

It tried get-hvglobalsession but not sure how to use it.  Do I have to pass any variables to it?

Thanks,

Chris

0 Kudos
cbadman
Contributor
Contributor

Hi LuCD:

We are finally getting done with the semester, so now I can work on this again.

I get the sessionData but I need to correlate it to a VDI and a user.

Any thoughts?

This is the output.

PS C:\> $Sessions.Results.SessionData

SessionType           : DESKTOP

SessionProtocol       : PCOIP

SessionState          : CONNECTED

StartTime             : 4/24/2018 9:33:23 PM

DisconnectTime        :

LastSessionDurationMS : 91477

BrokeredRemotely      : False

ResourcedRemotely     : False

Unauthenticated       :

Thanks,

Chris

0 Kudos
Magneet
Hot Shot
Hot Shot

that's only the sessiondata you are looking at, you will need to use the id's from the referencedata to get the actual user desktop and machine information. Use those id's against get-hvinternalname to get the names

0 Kudos
cbadman
Contributor
Contributor

Thanks Magneet:

I got lost googling about the reference data. (Sorry I am really new to this).

Any suggestions on where to read up on it?

By the way, about get-hvglobalsession? I am not sure how to use it.  Do I have to pass any variables to it?

Thanks again for all your help.

Chris

0 Kudos
Magneet
Hot Shot
Hot Shot

nope, currently it doesn't accept any variables it just finds all sessions within a cpa for you. If you don't have a cpa or only want sessions from the pod you are connected to you need to use get-hvlocalsession

0 Kudos
cbadman
Contributor
Contributor

Hi Magneet:


Sorry, I am really lost on this.

PS C:\Users\admin> get-hvlocalsession

Id                  NamesData                  ReferenceData                       SessionData

--                  ---------                  -------------                       -----------

VMware.Hv.SessionId VMware.Hv.SessionNamesData VMware.Hv.SessionLocalReferenceData VMware.Hv.SessionData

VMware.Hv.SessionId VMware.Hv.SessionNamesData VMware.Hv.SessionLocalReferenceData VMware.Hv.SessionData

VMware.Hv.SessionId VMware.Hv.SessionNamesData VMware.Hv.SessionLocalReferenceData VMware.Hv.SessionData

is there a quick tutorial on using vmware.Hv?

Thanks,

Chris

0 Kudos
Magneet
Hot Shot
Hot Shot

hmmz I thought I had blogged about it, will put something together for you but essentially you can do this (get-hvglobalsession).namesdata and so on to get the information or better do $sessions=get-hvglobalsession and then $sessions.namesdata and so on.

0 Kudos
Magneet
Hot Shot
Hot Shot

0 Kudos
cbadman
Contributor
Contributor

Hi Magneet:

Thanks. I think i got it, using the NamesData and the SessionsData.

Thanks again,

Chris

0 Kudos