I am trying to create a web interface to allow us to monitor how many users are logged in to our 2008r2 terminal server farm. I have a script that is a good starting point and I have tweaked it for our environment, but I need to add some things and I don't know how. I need to get unique logins... here is my starting point....
$ComputerList = "RDS1","RDS2","RDS3" foreach ($ComputerName in $ComputerList){ $UserCount=0 $colEvents = Get-WinEvent -ComputerName $ComputerName - LogName "Microsoft-Windows-TerminalServices- LocalSessionManager/Operational" | Where {$_.ID -eq "21"} | Select -Property TimeCreated, Message Write-Host "`nServer Date Login Time Username" Foreach ($Event in $colEvents) { $EventTimeCreated = $Event.TimeCreated $EventMessage = $Event.Message -split "`n" | Select-Object-Index "2" $EventMessageUser = $EventMessage.Substring(6) Write-Host "$ComputerName $EventTimeCreated $EventMessageUser" $UserCount = $UserCount + 1 } Write-Host "Number of Users: $UserCount" } ….So first things first- How to I get unique logins... Second, how do I get active logins, and third, how do I get the first script into the format of the second script? To get unique logins, Obviously, I would have to have some sort of array that the logins are stored, on the condition that there isn't already that value in the array... but I don't know how. The second would be a matter of matching an ID with one already in the list that doesn't have a logout event.... not sure how to do that either. Any ideas? I appreciate the help.
