VMware Cloud Community
Dragonfly26
Contributor
Contributor
Jump to solution

VMware view get users

Hi

I have to make a script for our VMware view environment that gets the amount of users that have logged in last week.

but I'm stuck. Smiley Sad

i got so far with my script.

$pss = New-PSSession "view-broker"

Invoke-Command -Session $pss -ScriptBlock {

##### Add View Snanpin.

if(-not (Get-PSSnapin VMware.View.Broker -ErrorAction SilentlyContinue))

{

   Add-PSSnapin VMware.View.Broker

}

#*****************************************

Get-EventReport  -ViewName user_events | where {$_.eventtype -eq "AGENT_CONNECTED"}  }

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Try with the StartDate parameter

Get-EventReport  -ViewName user_events -StartDate (Get-Date).AddDays(-7) |

where {$_.eventtype -eq "AGENT_CONNECTED"}

That should give the events for the last 7 days.


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

View solution in original post

0 Kudos
4 Replies
LucD
Leadership
Leadership
Jump to solution

Do you get any error messages ?


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

0 Kudos
Dragonfly26
Contributor
Contributor
Jump to solution

no  i do get output. the problem i'm facing is how to select the last 7 days.

if i look at one of the output and do a get-member of "time" than it tells me its  a "System.String" and not a "System.dateTime"

This is one of the output:

Get-EventReport  -ViewName user_events | where {$_.eventtype -eq "AGENT_CONNECTED"} | select -First 1 | fl *

report-result      : 0

eventid            : 19766

module             : Agent

eventtype          : AGENT_CONNECTED

time               : 2013-04-12 16:47:04.113

source             : com.vmware.vdi.events.client.EventLogger

severity           : INFO

moduleandeventtext : User ********* has disconnected from machine *******

userdisplayname    : ************

usersid            : S-1-5-21-*******66342-2480738168-*****

desktopid          : ********

desktopdisplayname :

machineid          : 3f8460c7-bb26-460c-ab28-f59d1*******

0 Kudos
LucD
Leadership
Leadership
Jump to solution

Try with the StartDate parameter

Get-EventReport  -ViewName user_events -StartDate (Get-Date).AddDays(-7) |

where {$_.eventtype -eq "AGENT_CONNECTED"}

That should give the events for the last 7 days.


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

0 Kudos
Dragonfly26
Contributor
Contributor
Jump to solution

Thanks Luc!

That is what i was looking for.

0 Kudos