Notification

Icon
Error

LSagent force a scan

Posted: Tuesday, March 12, 2019 4:48:31 PM(UTC)
David Cocke

David Cocke

Member Original PosterPosts: 3
1
Like
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.
Esben.D
#1Esben.D Member Administration Posts: 2,010  
posted: 3/13/2019 5:20:12 PM(UTC)
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.
Bruce.B
#2Bruce.B Member Administration Posts: 563  
posted: 6/7/2019 7:01:43 AM(UTC)
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.
Joe Conger
#3Joe Conger Member Posts: 3  
posted: 8/28/2019 2:04:29 PM(UTC)
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?
Orion Poplawski
#4Orion Poplawski Member Posts: 5  
posted: 4/17/2021 4:46:49 PM(UTC)
Originally Posted by: David Cocke Go to Quoted Post
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:
Code:

---
- 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
David Cocke
#5David Cocke Member Original PosterPosts: 3  
posted: 5/5/2021 1:06:47 PM(UTC)
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.

Code:

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

Active Discussions

Lansweeper Full asset report with and without ad relationship
by  teddyh2o   Go to last post Go to first unread
Last post: 6/18/2021 8:28:24 PM(UTC)
Report Center Show newly discovered software
by  CyberCitizen  
Go to last post Go to first unread
Last post: 6/16/2021 12:06:21 AM(UTC)
Lansweeper Multiple Devices Owned by Users (asset relations)
by  Charles S.   Go to last post Go to first unread
Last post: 6/15/2021 9:38:26 PM(UTC)
Lansweeper Show Date Without Time
by  RC62N  
Go to last post Go to first unread
Last post: 6/15/2021 9:04:47 PM(UTC)
Lansweeper Windows 10 Version Chart
by  RC62N   Go to last post Go to first unread
Last post: 6/14/2021 6:16:52 PM(UTC)
Lansweeper LSAgent Report
by  brodiemac-too  
Go to last post Go to first unread
Last post: 6/14/2021 5:27:29 PM(UTC)