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)
Please log in to answer
Posted by:
UcMerrill
19 years ago
Posted by:
glwday
19 years ago
Posted by:
Byoung4now
18 years ago
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
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.
so that the conversation will remain readable.