Цитата: Нет ни у кого готового скрипта для сбора данных о залогиненных юзерах на компах?
'---------------------------------------------------------------
' Вывод списка пользователей отлогиненых на компьютерах
'---------------------------------------------------------------
Const ADS_SCOPE_SUBTREE = 2
on error resume next
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection
' В следующей строке необходимо заменить имя домена
objCommand.CommandText = "Select Name, Location from 'LDAP://DC=domain,DC=name' " & "where objectClass='computer'"
objCommand.Properties("Page Size") = 1000
objCommand.Properties("Timeout") = 30
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
objCommand.Properties("Cache Results") = False
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst
Do Until objRecordSet.EOF
Wscript.Echo "Computer Name: " & objRecordSet.Fields("Name").Value
strComputer = "."
Set objWMIService = GetObject(_
"winmgmts:\\" & strComputer & "\root\cimv2")
Set colPings = objWMIService.ExecQuery _
("Select * From Win32_PingStatus where Address = '"& objRecordSet.Fields("Name").Value &"'")
For Each objStatus in colPings
If IsNull(objStatus.StatusCode) _
or objStatus.StatusCode<>0 Then
WScript.Echo "Computer did not respond."
Else
Wscript.Echo "Computer responded."
'Получение имени отлогиненного пользователя
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
&objRecordSet.Fields("Name").Value & "\root\cimv2")
Set colComputer = objWMIService.ExecQuery _
("Select * from Win32_ComputerSystem")
For Each objComputer in colComputer
Wscript.Echo "User Name = " & objComputer.UserName _
& VBNewLine & "Computer Name = " & objComputer.Name
'Nextscript.Echo objComputer.UserName
Next
End If
Next
Wscript.Echo "Location: " & objRecordSet.Fields("Location").Value
objRecordSet.MoveNext
Loop