Returns information about all the Terminal Services accounts on a computer.

This script was tested using Object REXX 2.1.0 for Microsoft Windows, available from IBM.

Object REXX
Edit|Remove
strComputer = "."
objWMIService = .OLEObject~GetObject("winmgmts:\\"||strComputer||"\root\CIMV2")
do objItem over objWMIService~ExecQuery("Select * from Win32_TSAccount")
    say "Account Name:" objItem~AccountName
    say "Audit Fail:" objItem~AuditFail
    say "Audit Success:" objItem~AuditSuccess
    say "Caption:" objItem~Caption
    say "Description:" objItem~Description
    say "Permissions Allowed:" objItem~PermissionsAllowed
    say "Permissions Denied:" objItem~PermissionsDenied
    say "Setting ID:" objItem~SettingID
    say "SID:" objItem~SID
    say "Terminal Name:" objItem~TerminalName
end