cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
davidc97
Engaged Sweeper II
Is there a way to force an inventory scan when using the Lansweeper Agent? I found where you can adjust the polling schedule, but sometimes we're making changes on an endpoint and would like for those changes to appear right away instead of waiting until the next polling period.
1 ACCEPTED SOLUTION
Bruce_B
Lansweeper Alumni
For those reading this thread in the future:
  • Do we have flying cars yet?
  • I don't recommend using ForceScan=1 to force LsAgent scans, as this will result in an LsAgent scan being performed at every "check interval", i.e. 15 minutes. Clearing the LastScan and LastSent values and restarting the service is the superior option, as this will trigger just a single scan and afterwards the asset will follow its schedule.

View solution in original post

6 REPLIES 6
davidc97
Engaged Sweeper II
Orion Poplawski, thank you for your post above. I'm not familiar with Ansible play, but with your code, I figured out the essence of what it does. I've created a PowerShell equivalent and seems to work fairly well in my limited testing.

The code below changes the timestamp to be 90 days prior from the original date on the file. It likely does not need to be that long.


Stop-Service LansweeperAgentService
Start-Sleep -s 5
$(Get-Item "C:\Program Files (x86)\LansweeperAgent\LsAgent.ini").lastwritetime=$(Get-Date).adddays(-90)
Start-Service LansweeperAgentService
Blast34345
Engaged Sweeper II

Doesn't work for me thus i made a PS script to replace two strings in .ini file with blank value...

 

Stop-Service LansweeperAgentService
Start-Sleep -s 5
$file = 'C:\Program Files (x86)\LansweeperAgent\LsAgent.ini'
$regex = 'LastScan.*'
(Get-Content $file) -replace $regex, 'LastScan=' | Set-Content $file
$regex = 'LastSent.*'
(Get-Content $file) -replace $regex, 'LastSent=' | Set-Content $file
Start-Service LansweeperAgentService

 

opoplawski
Engaged Sweeper III
David Cocke wrote:
Is there a way to force an inventory scan when using the Lansweeper Agent? I found where you can adjust the polling schedule, but sometimes we're making changes on an endpoint and would like for those changes to appear right away instead of waiting until the next polling period.


This is the ansible play (lansweeper-rescan.yml) we use to force a rescan:

---
- hosts: windows
gather_facts: no
tasks:
- name: "Stop LansweeperAgent"
win_service:
name: LansweeperAgentService
state: stopped
- name: "Remove timestamps from LsAgent.ini"
win_lineinfile:
path: C:\Program Files (x86)\LansweeperAgent\LsAgent.ini
regex: ^Last
state: absent
- name: "Start LansweeperAgent"
win_service:
name: LansweeperAgentService
state: started
jconger
Engaged Sweeper
I was just wondering if I could maintain an LsAgent.ini template that removes all the custom settings associated with the asset? If I want to force a scan can I just copy/overwrite the LsAgent.ini file with the template I created below. If I overwrite the file and then restart the Lanseeper Agent Service it appears to force a rescan. The service restart appears to initialize and set the ini settings. Unless I'm missing something, this method seems to be easier to manage and trigger remotely.

[default]
Server=192.168.11.33
Port=9524
AgentKey=
Enabled=1
AssetId=
ComputerName=
LastScan=
LastSent=
Status=Running
Version=7.1.110.2

Please advise if this is not a good option. Does it create duplicate assets?
Bruce_B
Lansweeper Alumni
For those reading this thread in the future:
  • Do we have flying cars yet?
  • I don't recommend using ForceScan=1 to force LsAgent scans, as this will result in an LsAgent scan being performed at every "check interval", i.e. 15 minutes. Clearing the LastScan and LastSent values and restarting the service is the superior option, as this will trigger just a single scan and afterwards the asset will follow its schedule.
Esben_D
Lansweeper Employee
Lansweeper Employee
There is a dirty way 😉

If you want to force an immediate LsAgent scan, you can clear LastSent/LastScan or add a ForceScan=1 entry to LsAgent.ini and restart the service.

You'll still be dependent on the interval at which Lansweeper pulls data from the cloud relay if you are using that.

New to Lansweeper?

Try Lansweeper For Free

Experience Lansweeper with your own data.
Sign up now for a 14-day free trial.

Try Now