→ 🚀What's New? Join Us for the Fall Product Launch! Register Now !
‎01-02-2009 09:11 PM
'****************************************************************************
' This script created by Travis Brackett (travmeister@gmail.com)
'
'Stolen from http://www.rlmueller.net and netnerds.net
'
' This script finds all computers in AD and attempts to run LSclient.exe
' On each machine using Sysinternals Psexec.
'
'Requirements: AD Domain, LSclient.exe in a network location, Sysinternals
'Psexec (http://download.sysinternals.com/Files/PsTools.zip) and a working
'Lansweeper install
'
'Creates a temp file in your %temp% directory for each computer so you can
'Track output of the process. Not recommended if you have tons of computers
'
' NO WARRANTIES, USE THIS AT YOUR OWN RISK, etc.
'*****************************************************************************
Dim strPsexecpath,strLsclientpath,strServerName
'Location of psexec.exe
strPsexecpath = "\\server01\pstools\psexec.exe"
'Location of lsclient.exe
strLsclientpath = "\\contoso.com\netlogon\lsclient.exe"
'Name of the server running the Lansweeper service
strServerName = "LSSERVER"
Set objAdRootDSE = GetObject("LDAP://RootDSE")
Set objRS = CreateObject("adodb.recordset")
Set objShell = CreateObject("Wscript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
strTemp = objShell.ExpandEnvironmentStrings("%TEMP%")
varConfigNC = objAdRootDSE.Get("defaultNamingContext")
strConnstring = "Provider=ADsDSOObject"
strWQL = "SELECT * FROM 'LDAP://" & varConfigNC & "' WHERE objectCategory= 'Computer'"
objRS.Open strWQL, strConnstring
Do until objRS.eof
Set objComputer = GetObject(objRS.Fields.Item(0))
strComputer = objComputer.CN
objRS.movenext
Set objComputer = Nothing
If (IsConnectible(strComputer, 1, 750) = True) Then
RETURN = objShell.Run ("%comspec% /c " & strPsexecpath & " \\" & strComputer & " -c " & strLsclientpath & " " & strServerName & " > " & strTemp & "\" & strComputer & ".tmp", 0)
End If
Loop
objRS.close
Set objRS = Nothing
Set objAdRootDSE = Nothing
Function IsConnectible(ByVal strHost, ByVal intPings, ByVal intTO)
' Returns True if strHost can be pinged.
' Based on a program by Alex Angelopoulos and Torgeir Bakken.
strTempFile = strTemp & "\RunResult.tmp"
Dim objFile, strResults
If (intPings = "") Then
intPings = 2
End If
If (intTO = "") Then
intTO = 750
End If
Const OpenAsDefault = -2
Const FailIfNotExist = 0
Const ForReading = 1
objShell.Run "%comspec% /c ping -n " & intPings & " -w " & intTO _
& " " & strHost & ">" & strTempFile, 0, True
Set objFile = objFSO.OpenTextFile(strTempFile, ForReading, _
FailIfNotExist, OpenAsDefault)
strResults = objFile.ReadAll
objFile.Close
Select Case InStr(strResults, "TTL=")
Case 0
IsConnectible = False
Case Else
IsConnectible = True
End Select
End Function
set objShell = Nothing
‎03-19-2009 05:22 PM
‎03-18-2009 06:03 PM
‎03-18-2009 05:42 PM
‎01-09-2009 06:39 PM
‎01-09-2009 06:24 PM
Set objAdRootDSE = GetObject("LDAP://dc=antarctica,dc=contoso,dc=com")
‎01-09-2009 06:15 PM
Experience Lansweeper with your own data. Sign up now for a 14-day free trial.
Try Now