Returns a list of threads and thread states for each process running on a computer.

This script was tested using Kixtart 2001 (412) for Microsoft Windows, available from Kixtart.org.

Kixtart
Edit|Remove
$strComputer = "."
$objWMIService = GetObject("winmgmts:\\"+ $strComputer + "\root\cimv2")
$colItems = $objWMIService.ExecQuery("Select * from Win32_Thread")
For Each $objItem in $colItems
    ? "Caption:" + $objItem.Caption
    ? "Creation Class Name:" + $objItem.CreationClassName
    ? "CS Creation Class Name:" + $objItem.CSCreationClassName
    ? "CS Name:" + $objItem.CSName
    ? "Description:" + $objItem.Description
    ? "Elapsed Time:" + $objItem.ElapsedTime
    ? "Execution State:" + $objItem.ExecutionState
    ? "Handle:" + $objItem.Handle
    ? "Install Date:" + $objItem.InstallDate
    ? "Kernel Mode Time:" + $objItem.KernelModeTime
    ? "Name:" + $objItem.Name
    ? "OS Creation Class Name:" + $objItem.OSCreationClassName
    ? "OS Name:" + $objItem.OSName
    ? "Priority:" + $objItem.Priority
    ? "Priority Base:" + $objItem.PriorityBase
    ? "Process Creation Class Name:" + $objItem.ProcessCreationClassName
    ? "Process Handle:" + $objItem.ProcessHandle
    ? "Start Address:" + $objItem.StartAddress
    ? "Status:" + $objItem.Status
    ? "Thread State:" + $objItem.ThreadState
    ? "Thread Wait Reason:" + $objItem.ThreadWaitReason
    ? "User Mode Time:" + $objItem.UserModeTime
Next