Hi there, first post
I thought I would share with you all how I deployed lansweeper in my environment. I created the following vbscript which queries the active directory domain for computers, pings them, and remotely executes lsclient.exe using psexec on the ones that respond. Feel free to use it, hack it, do whatever you want with it. Suggestions are appreciated.
Just change your variables to match the locations appropriate for your environment and let 'er rip. *must be run as a user in the "administrators" group on the local machines*
'****************************************************************************
' 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