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.
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"} }
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
Do you get any error messages ?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
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*******
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
Thanks Luc!
That is what i was looking for.