All Forums >> [Scripting] >> Post a VBScript >> Find all machines a user is logged onto Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
It took ages to runthrough all domain computers as there were many obsolete computer accounts in AD. I culled out heaps by writing an Obsoleteness function and then it still took an hour to run through ~1000 computers, I need to speed up the pingstatus function or replace it with something faster if I want to make this script really powerfull but it is still ok if you want to find all machines a user is logged onto via vbscript.
Posts: 123
Score: 2
Joined: 7/13/2006
From: Australia
Status: offline
If no machine name is specified as an argument the script tries to check all computers in the domain. That section of the code relies on the following line
quote:
"Select Name, Location from 'LDAP://DC=MYDOMAIN,DC=COM" _
ensure you use your domain name here
Also you need to be a domain admin or a local admin of all domain computers or the script will fall over.
Does that help?
ps. You can skip the Obsoleteness function too if you want, I only wrote it because our domain has a heap of obsolete computer accounts in AD that the administrator has left in there.
Posts: 5
Score: 0
Joined: 10/10/2006
From: Grand Rapids, MI
Status: offline
Thanks for the script, works real nice. I do notice that it polls computers from AD kind of randomly, not from container to container or alphabetically, but it does get all of them.
Cool PingStatus function also, I've used this old school approach for ping verifies: It basically executes the dos PING command in a shell then reads and scans the output for "Reply From" for a Success. This way I can configure how many echo (-n) requests and timeout in milliseconds (-w) of each echo.
Posts: 123
Score: 2
Joined: 7/13/2006
From: Australia
Status: offline
I ended up using a similar piece of code to speed up a ping response, basically the same but with only one ping and a time out of 500
Function FastPing(strComputer) Set WshShell = WScript.CreateObject("WScript.Shell") return = WshShell.Run("ping "&strComputer&" -n 1 -w 500", 0, true) if return = 0 then FastPing= "Success" Else FastPing= "Failure" End if End function
cool meg! There are always adv and disv. When using the cmd .Exec ping option, its amazing faster but we get cmd popup, quite anoyoning for a big list! When using the Ping from WMI its too slow, but clean... (maybe adding the progessbar would make it look cool :) ) would be perfect if the ping function could be faster, maybe a parameter for replay wait.. dunno I was able to get the list using a better function (much much faster) and no need to manually enter the OU or Domain... the userdomain i get doing a echo of sys variable, but it can be retrieved using WMI or 2 other ways posted by ebgreen:
Within the next 24 hours I'll be releasing a new version of my tool MWLOGGEDON.
It will allow to you
a) Scan a machine for the logged on user b) Scan a domain for which machines a user is logged on to c) Scan a domain and return the logged on user for all machines.
Just awaiting confirmation from my "guinea pig" that all works as expected.