You can use Win32_PerfFormattedData_TermService_TerminalServices for This
Get-WMIObject Win32_PerfFormattedData_TermService_TerminalServices
It has these useful properties
ActiveSessions : 1
InactiveSessions : 1
TotalSessions : 2
Here is an Example Script
foreach($server in (Get-Content $file))
{
$count = (Get-WMIObject
Win32_PerfFormattedData_TermService_TerminalServices).TotalSessions
"There are {0} users on {1}" -f $count,$Server
}
"Ian_1" <fakeaddy@xxxxxx> wrote in message
news:0031F476-6BE1-4462-A090-8E212B3BC5F1@xxxxxx
> Looking for something at will just output "There are 32 users on Server1".
> If
> it was possbile to GET from a test file with server names so it would just
> read:
> There are 35 users on Server1
> There are 15 users on Server2
> There are 32 users on Server3
> There are 45 users on Server4
> There are 31 users on Server5
>
> That would be awesome. Thanks in advance-
>