Returns information about the Terminal Service service.

This script was tested using Perl 5.8.0.804 for Microsoft Windows, available from ActiveState.

Perl
Edit|Remove
use Win32::OLE('in');
use constant wbemFlagReturnImmediately => 0x10;
use constant wbemFlagForwardOnly => 0x20;

$computer = ".";
$objWMIService = Win32::OLE->GetObject
    ("winmgmts:\\\\$computer\\root\\CIMV2") or die "WMI connection failed.\n";
$colItems = $objWMIService->ExecQuery
    ("SELECT * FROM Win32_TerminalService","WQL",wbemFlagReturnImmediately | wbemFlagForwardOnly);

foreach my $objItem (in $colItems)
{
      print "Accept Pause: $objItem->{AcceptPause}\n";
      print "Accept Stop: $objItem->{AcceptStop}\n";
      print "Caption: $objItem->{Caption}\n";
      print "Check Point: $objItem->{CheckPoint}\n";
      print "Creation Class Name: $objItem->{CreationClassName}\n";
      print "Description: $objItem->{Description}\n";
      print "Desktop Interact: $objItem->{DesktopInteract}\n";
      print "Disconnected Sessions: $objItem->{DisconnectedSessions}\n";
      print "Display Name: $objItem->{DisplayName}\n";
      print "Error Control: $objItem->{ErrorControl}\n";
      print "Estimated Session Capacity: $objItem->{EstimatedSessionCapacity}\n";
      print "Exit Code: $objItem->{ExitCode}\n";
      print "Install Date: $objItem->{InstallDate}\n";
      print "Name: $objItem->{Name}\n";
      print "Path Name: $objItem->{PathName}\n";
      print "Process Id: $objItem->{ProcessId}\n";
      print "Raw Session Capacity: $objItem->{RawSessionCapacity}\n";
      print "Resource Constraint: $objItem->{ResourceConstraint}\n";
      print "Service Specific Exit Code: $objItem->{ServiceSpecificExitCode}\n";
      print "ServiceT ype: $objItem->{ServiceType}\n";
      print "Started: $objItem->{Started}\n";
      print "Start Mode: $objItem->{StartMode}\n";
      print "Start Name: $objItem->{StartName}\n";
      print "State: $objItem->{State}\n";
      print "Status: $objItem->{Status}\n";
      print "System Creation Class Name: $objItem->{SystemCreationClassName}\n";
      print "System Name: $objItem->{SystemName}\n";
      print "Tag Id: $objItem->{TagId}\n";
      print "Total Sessions: $objItem->{TotalSessions}\n";
      print "Wait Hint: $objItem->{WaitHint}\n";
      print "\n";
}