[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 748
  • Last Modified:

WMI \ WMIC or Powershell To Find total number of sessions

Does anyone know how to use WMI \ WmIC or Powershell to return the number of concurrent telnet sessions on a Windows 2003 sevrers ? I would like to see the same results as tlntadmn -s all.

Thanks
0
CaussyR
Asked:
CaussyR
  • 3
  • 2
1 Solution
 
Michael PfisterCommented:
Does it help to pull the output of tlntadmn into a powershell variable?


$output = & tlntadmn -s all
0
 
CaussyRAuthor Commented:
Thats exactly what I am looking for - thanks.

But one more question, now the contents of the concurrent sessions are in the $output variable. How do i count the number of sessions in the variable ?
0
 
Michael PfisterCommented:
No telnet server here, can you post the output of tlntadmn -s all? Please remove personal data.
0
 
CaussyRAuthor Commented:
Apologies for the dealy, please, see attached image.
Telnet.jpg
0
 
Michael PfisterCommented:
$output = & tlntadmn -s all 
$output.count 
$sessions = $output.count -3 # remove the header lines
$sessions

Open in new window



should give you the number of lines and number of sessions.
Its not clear from your screen shot if these are blank lines between each session number or if its just a display problem.
If these are blank lines the $session variable needs to be devided by 2

$sessions = ($output.count -3)/2

HTH
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now