Ok let’s do another script.
The script shows you who is connected to a domain controller.
This is accomplished through the WMI class “Win32_ServerSession”.
Enumerated are: prew2k username, hostname, workstation os and the time connected.
The script needs to be run as admin because of the wmi connection to the server.
Follow the next steps to run the script (admin rights needed):
- copy and paste the script in your favorite text editor
- change the value of strServer to the name of your domain controller (example: strServer = “srv001″)
- save the script (for example c:\temp\connected.vbs)
- open a command prompt
- go to “c:\temp”
- give “cscript connected.vbs” (without quotes) and enter
The script:
' Name : connected.vbs
' Description : script to enumerate who is connected to a domain controller
' Author : dirk adamsky - deludi bv
' Version : 1.00
' Date : 22-04-2010
' Level: intermediate
strServer = "domaincontroller"
Set objWMI = GetObject("winmgmts://" & strServer & "/root\cimv2")
Set objInstances = objWMI.InstancesOf("Win32_ServerSession",48)
For Each objInstance in objInstances
With objInstance
WScript.Echo .UserName & " ; " & .ComputerName & " ; " & .ClientType &_
.Name & " ; " & Round(.ActiveTime/60,0) & " minutes connected"
End With
Next
Set objInstances = Nothing
Set objWMI = Nothing
When you have problems/questions please post a reply or give a ‘star’ rating.
Happy scripting.
Best regards,
Dirk Adamsky – Deludi BV
Recent Comments