Contact Info

Crumbtrail

ActiveXperts.com » Administration » Scripts » WMI » jscript sample

Win32_PerfFormattedData_TermService_TerminalServicesSession jscript sample code

The foundations for Manageability in Windows is Windows Management Instrumentation (WMI; formerly WBEM) and WMI extensions for Windows Driver Model (WDM).

ActiveXperts Network Monitor provides the ability to build monitor check routines based on WMI. ActiveXperts has collected more than a hundred WMI samples. You can use these samples as a base for new check routines you can write yourself. The Win32_PerfFormattedData_TermService_TerminalServicesSession WMI class can be used in ActiveXperts Network Monitor to monitor your servers.


Sample Code

var wbemFlagReturnImmediately = 0x10;
var wbemFlagForwardOnly = 0x20;

var arrComputers = new Array("\localhost");
for (i = 0; i < arrComputers.length; i++) {
   WScript.Echo();
   WScript.Echo("==========================================");
   WScript.Echo("Computer: " + arrComputers[i]);
   WScript.Echo("==========================================");

   var objWMIService = GetObject("winmgmts:\\\\" + arrComputers[i] + "\\root\\CIMV2");
   var colItems = objWMIService.ExecQuery("SELECT * FROM Win32_PerfFormattedData_TermService_TerminalServicesSession", "WQL",
                                          wbemFlagReturnImmediately | wbemFlagForwardOnly);

   var enumItems = new Enumerator(colItems);
   for (; !enumItems.atEnd(); enumItems.moveNext()) {
      var objItem = enumItems.item();

      WScript.Echo("Caption: " + objItem.Caption);
      WScript.Echo("Description: " + objItem.Description);
      WScript.Echo("Frequency_Object: " + objItem.Frequency_Object);
      WScript.Echo("Frequency_PerfTime: " + objItem.Frequency_PerfTime);
      WScript.Echo("Frequency_Sys100NS: " + objItem.Frequency_Sys100NS);
      WScript.Echo("HandleCount: " + objItem.HandleCount);
      WScript.Echo("InputAsyncFrameError: " + objItem.InputAsyncFrameError);
      WScript.Echo("InputAsyncOverflow: " + objItem.InputAsyncOverflow);
      WScript.Echo("InputAsyncOverrun: " + objItem.InputAsyncOverrun);
      WScript.Echo("InputAsyncParityError: " + objItem.InputAsyncParityError);
      WScript.Echo("InputBytes: " + objItem.InputBytes);
      WScript.Echo("InputCompressedBytes: " + objItem.InputCompressedBytes);
      WScript.Echo("InputCompressFlushes: " + objItem.InputCompressFlushes);
      WScript.Echo("InputCompressionRatio: " + objItem.InputCompressionRatio);
      WScript.Echo("InputErrors: " + objItem.InputErrors);
      WScript.Echo("InputFrames: " + objItem.InputFrames);
      WScript.Echo("InputTimeouts: " + objItem.InputTimeouts);
      WScript.Echo("InputTransportErrors: " + objItem.InputTransportErrors);
      WScript.Echo("InputWaitForOutBuf: " + objItem.InputWaitForOutBuf);
      WScript.Echo("InputWdBytes: " + objItem.InputWdBytes);
      WScript.Echo("InputWdFrames: " + objItem.InputWdFrames);
      WScript.Echo("Name: " + objItem.Name);
      WScript.Echo("OutputAsyncFrameError: " + objItem.OutputAsyncFrameError);
      WScript.Echo("OutputAsyncOverflow: " + objItem.OutputAsyncOverflow);
      WScript.Echo("OutputAsyncOverrun: " + objItem.OutputAsyncOverrun);
      WScript.Echo("OutputAsyncParityError: " + objItem.OutputAsyncParityError);
      WScript.Echo("OutputBytes: " + objItem.OutputBytes);
      WScript.Echo("OutputCompressedBytes: " + objItem.OutputCompressedBytes);
      WScript.Echo("OutputCompressFlushes: " + objItem.OutputCompressFlushes);
      WScript.Echo("OutputCompressionRatio: " + objItem.OutputCompressionRatio);
      WScript.Echo("OutputErrors: " + objItem.OutputErrors);
      WScript.Echo("OutputFrames: " + objItem.OutputFrames);
      WScript.Echo("OutputTimeouts: " + objItem.OutputTimeouts);
      WScript.Echo("OutputTransportErrors: " + objItem.OutputTransportErrors);
      WScript.Echo("OutputWaitForOutBuf: " + objItem.OutputWaitForOutBuf);
      WScript.Echo("OutputWdBytes: " + objItem.OutputWdBytes);
      WScript.Echo("OutputWdFrames: " + objItem.OutputWdFrames);
      WScript.Echo("PageFaultsPersec: " + objItem.PageFaultsPersec);
      WScript.Echo("PageFileBytes: " + objItem.PageFileBytes);
      WScript.Echo("PageFileBytesPeak: " + objItem.PageFileBytesPeak);
      WScript.Echo("PercentPrivilegedTime: " + objItem.PercentPrivilegedTime);
      WScript.Echo("PercentProcessorTime: " + objItem.PercentProcessorTime);
      WScript.Echo("PercentUserTime: " + objItem.PercentUserTime);
      WScript.Echo("PoolNonpagedBytes: " + objItem.PoolNonpagedBytes);
      WScript.Echo("PoolPagedBytes: " + objItem.PoolPagedBytes);
      WScript.Echo("PrivateBytes: " + objItem.PrivateBytes);
      WScript.Echo("ProtocolBitmapCacheHitRatio: " + objItem.ProtocolBitmapCacheHitRatio);
      WScript.Echo("ProtocolBitmapCacheHits: " + objItem.ProtocolBitmapCacheHits);
      WScript.Echo("ProtocolBitmapCacheReads: " + objItem.ProtocolBitmapCacheReads);
      WScript.Echo("ProtocolBrushCacheHitRatio: " + objItem.ProtocolBrushCacheHitRatio);
      WScript.Echo("ProtocolBrushCacheHits: " + objItem.ProtocolBrushCacheHits);
      WScript.Echo("ProtocolBrushCacheReads: " + objItem.ProtocolBrushCacheReads);
      WScript.Echo("ProtocolGlyphCacheHitRatio: " + objItem.ProtocolGlyphCacheHitRatio);
      WScript.Echo("ProtocolGlyphCacheHits: " + objItem.ProtocolGlyphCacheHits);
      WScript.Echo("ProtocolGlyphCacheReads: " + objItem.ProtocolGlyphCacheReads);
      WScript.Echo("ProtocolSaveScreenBitmapCacheHitRatio: " + objItem.ProtocolSaveScreenBitmapCacheHitRatio);
      WScript.Echo("ProtocolSaveScreenBitmapCacheHits: " + objItem.ProtocolSaveScreenBitmapCacheHits);
      WScript.Echo("ProtocolSaveScreenBitmapCacheReads: " + objItem.ProtocolSaveScreenBitmapCacheReads);
      WScript.Echo("ThreadCount: " + objItem.ThreadCount);
      WScript.Echo("Timestamp_Object: " + objItem.Timestamp_Object);
      WScript.Echo("Timestamp_PerfTime: " + objItem.Timestamp_PerfTime);
      WScript.Echo("Timestamp_Sys100NS: " + objItem.Timestamp_Sys100NS);
      WScript.Echo("TotalAsyncFrameError: " + objItem.TotalAsyncFrameError);
      WScript.Echo("TotalAsyncOverflow: " + objItem.TotalAsyncOverflow);
      WScript.Echo("TotalAsyncOverrun: " + objItem.TotalAsyncOverrun);
      WScript.Echo("TotalAsyncParityError: " + objItem.TotalAsyncParityError);
      WScript.Echo("TotalBytes: " + objItem.TotalBytes);
      WScript.Echo("TotalCompressedBytes: " + objItem.TotalCompressedBytes);
      WScript.Echo("TotalCompressFlushes: " + objItem.TotalCompressFlushes);
      WScript.Echo("TotalCompressionRatio: " + objItem.TotalCompressionRatio);
      WScript.Echo("TotalErrors: " + objItem.TotalErrors);
      WScript.Echo("TotalFrames: " + objItem.TotalFrames);
      WScript.Echo("TotalProtocolCacheHitRatio: " + objItem.TotalProtocolCacheHitRatio);
      WScript.Echo("TotalProtocolCacheHits: " + objItem.TotalProtocolCacheHits);
      WScript.Echo("TotalProtocolCacheReads: " + objItem.TotalProtocolCacheReads);
      WScript.Echo("TotalTimeouts: " + objItem.TotalTimeouts);
      WScript.Echo("TotalTransportErrors: " + objItem.TotalTransportErrors);
      WScript.Echo("TotalWaitForOutBuf: " + objItem.TotalWaitForOutBuf);
      WScript.Echo("TotalWdBytes: " + objItem.TotalWdBytes);
      WScript.Echo("TotalWdFrames: " + objItem.TotalWdFrames);
      WScript.Echo("VirtualBytes: " + objItem.VirtualBytes);
      WScript.Echo("VirtualBytesPeak: " + objItem.VirtualBytesPeak);
      WScript.Echo("WorkingSet: " + objItem.WorkingSet);
      WScript.Echo("WorkingSetPeak: " + objItem.WorkingSetPeak);
   }
}