Get-hvlocalsession for multiple users

This post was originally published on this site

Hi guys,

 

I am trying to make a script which should give session details of multiple users such as username,login time and logout time.

 

I could get the required details for all the users by below script. But dont know how to get it for multiple users. ie by importing limited no of usernames in a text file.

 

Get-hvlocalsession | ForEach-Object -Process {

$dtformat = “dd-mm-yy HH:mm”

$ls = $_

” | select @{N=”Emp Id”;E={$ls.NamesData.UserName.Replace(“Domainname”,””)}},

  @{N=”Login Time”;E={$ls.sessiondata.StartTime.ToString($dtformat)}},

  @{N=”Logoff Time”;E={$ls.sessiondata.DisconnectTime.ToString($dtformat)}}

}

 

Any help?

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.