/build/static/layout/Breadcrumb_cap_w.png

Script to check who is logged on?

I am looking to write a script to check who is logged on, on a list of remote machines, any pointers would be greatly appreciated

0 Comments   [ + ] Show comments

Answers (4)

Posted by: UcMerrill 18 years ago
Senior Yellow Belt
0
Try this

strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_ComputerSystem")



For Each objItem in colItems

WScript.Echo strComputer & objItem.UserName
Next
Posted by: Naffcat 18 years ago
Senior Purple Belt
0
Thanks
Posted by: glwday 18 years ago
Orange Belt
0
Please excuse my ignorance, but how would I use the above script with a list of assets I want to query?

Thanks
Posted by: Byoung4now 18 years ago
Senior Yellow Belt
0
If it's a small list or a one time job you could do a array.
If it's a big list or you want to reuse the script I would have it read a text file.

Something like

Set FSO = CreateObject("Scripting.FileSystemObject")
Set Fin = Fso.OpenTextFile("C:\SvrList.txt", 1)
Do While Fin.AtEndOfStream <> True
strComputer = Fin.readline
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_ComputerSystem")
For Each objItem in colItems
WScript.Echo strComputer & objItem.UserName
Next
Loop
Fin.close
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ