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: 1,990  
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: 562  
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 Creating a count
by  Brianne   Go to last post Go to first unread
Last post: Yesterday at 6:12:49 PM(UTC)
Lansweeper Some reports shows dublicated assets
by  Andy.S  
Go to last post Go to first unread
Last post: Yesterday at 9:46:37 AM(UTC)
Lansweeper Adding "multi-part" Conditions to Reports
by  Brandon   Go to last post Go to first unread
Last post: 5/13/2021 1:52:17 PM(UTC)
Report Center Microsoft Outlook email bug EX255650
by  Esben.D  
Go to last post Go to first unread
Last post: 5/12/2021 2:30:16 PM(UTC)
Lansweeper Patch Tuesday May 2021
by  Esben.D   Go to last post Go to first unread
Last post: 5/11/2021 8:13:06 PM(UTC)
Lansweeper Report showing only Wi-Fi Devices and MAC addresses
by  Andy.S  
Go to last post Go to first unread
Last post: 5/11/2021 2:23:24 PM(UTC)
Lansweeper Modifying Purchase Date / Yearly Refresh Report
by  Cripple.Zero  
Go to last post Go to first unread
Last post: 5/7/2021 7:06:47 PM(UTC)