cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
AdmJLovejoy
Champion Sweeper
Is it possible to Start/Stop AD Active Scanning from the command line, or vbscript?
Thanks, Jim Lovejoy __________________________________________________________________________________________________ James W. Lovejoy | IBM - Cloud Managed Services Delivery | Infrastructure Architect (Windows Server ...
1 ACCEPTED SOLUTION
AdmJLovejoy
Champion Sweeper
This worked...Do you see any issues?

ScanMode(WScript.Arguments.Item(0))

Function ScanMode(Mode)

Dim ConWSH, strConnection, strSQL1, rs1, adOpenForwardOnly

Set ConWSH=WScript.CreateObject("ADODB.Connection")

strConnection = "Driver={SQL Server};Server=DBSERVER;Trusted_Connection=yes;Database=LansweeperDB;"
with ConWSH
.ConnectionString=strConnection
.ConnectionTimeout=25
.CommandTimeout=25
.Open
end with

strSQL1 = "Update tsysconfig Set activescanning='" & Mode & "'"

set rs1=createobject("ADODB.Recordset")
with rs1
.activeconnection=ConWSH
.CursorType=adOpenForwardOnly
.CursorLocation=3
.open strSQL1
End With
End Function
Thanks, Jim Lovejoy __________________________________________________________________________________________________ James W. Lovejoy | IBM - Cloud Managed Services Delivery | Infrastructure Architect (Windows Server ...

View solution in original post

5 REPLIES 5
AdmJLovejoy
Champion Sweeper
That's not an issue. I Will be stopping the local Lansweeper service, and remotely starting another one on a domain controller that can communicate to member servers that are outside of the primary network. I just needed a way to turn off Active Scanning, and turn it back on after the scans complete on those servers. This should do it until v4 comes out.
Thanks, Jim Lovejoy __________________________________________________________________________________________________ James W. Lovejoy | IBM - Cloud Managed Services Delivery | Infrastructure Architect (Windows Server ...
Hemoco
Lansweeper Alumni
If it works ok, note that it might take 15 minutes to be active. (the service checks this value every 15 minutes)
AdmJLovejoy
Champion Sweeper
This worked...Do you see any issues?

ScanMode(WScript.Arguments.Item(0))

Function ScanMode(Mode)

Dim ConWSH, strConnection, strSQL1, rs1, adOpenForwardOnly

Set ConWSH=WScript.CreateObject("ADODB.Connection")

strConnection = "Driver={SQL Server};Server=DBSERVER;Trusted_Connection=yes;Database=LansweeperDB;"
with ConWSH
.ConnectionString=strConnection
.ConnectionTimeout=25
.CommandTimeout=25
.Open
end with

strSQL1 = "Update tsysconfig Set activescanning='" & Mode & "'"

set rs1=createobject("ADODB.Recordset")
with rs1
.activeconnection=ConWSH
.CursorType=adOpenForwardOnly
.CursorLocation=3
.open strSQL1
End With
End Function
Thanks, Jim Lovejoy __________________________________________________________________________________________________ James W. Lovejoy | IBM - Cloud Managed Services Delivery | Infrastructure Architect (Windows Server ...
AdmJLovejoy
Champion Sweeper
Does this look right? The usage would be .\ScanMode.vbs True or .\ScanMode.vbs False

WScript.Echo ScanMode(WScript.Arguments.Item(0))

Function ScanMode(Mode)

Option Explicit
Dim ConWSH, strConnection, strSQL1, Mode, rs1, adOpenForwardOnly

Set ConWSH=WScript.CreateObject("ADODB.Connection")

strConnection = "Driver={SQL Server};Server=DBSERVER;User ID=DOMAIN\USER;Password=pwd;Database=LansweeperDB;"
with ConWSH
.ConnectionString=strConnection
.ConnectionTimeout=25
.CommandTimeout=25
.Open
end with

strSQL1 = "Update tsysconfig Set activescanning='" & Mode & "'"

set rs1=createobject("ADODB.Recordset")
with rs1
.activeconnection=ConWSH
.CursorType=adOpenForwardOnly
.CursorLocation=3
.open strSQL1

End With

End Function
Thanks, Jim Lovejoy __________________________________________________________________________________________________ James W. Lovejoy | IBM - Cloud Managed Services Delivery | Infrastructure Architect (Windows Server ...
Hemoco
Lansweeper Alumni
You can directly access sqlserver from vbscript.

You need to change the "activescanning" field in table tsysconfig.