→ 🚀What's New? Explore Lansweeper's Fall 2024 Updates! Fall Launch Blog !

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
ErikT
Lansweeper Tech Support
Lansweeper Tech Support

Your LsAgent clients are configured to scan your assets twice a day, or to follow whichever schedule you set up. However, you're making changes to an asset, and you want these changes to immediately appear in the database, rather than waiting for the next scheduled scan.
You stop and restart the agent, but nothing seems to happen.

What happened?

If you've tried stopping and restarting the LsAgent but noticed that nothing seems to change, don't worry; this behavior is by design. LsAgent will only scan on the set time intervals, as configured in the .ini file.

Now what?

You can force LsAgent to start scanning immediately: 

  1. On the target asset, navigate to \Program Files (x86)\LansweeperAgent
  2. Open the LsAgent.ini file.
  3. Clear the LastScan and LastSent values.
  4. Restart the agent.

LsAgent will now start scanning the target asset, and any changes will appear in the database.



Was this post helpful? Leave a Kudo!
Did you have a similar issue and a different solution? Share your work in the comments below and help your fellow IT Hero's!
More questions? Browse our  Quick Tech Solutions  or  Community Forum.


If you can't find what you're looking for, create a post in our Community Forum.



4 Comments
rinks
Champion Sweeper

Is there a way to force a rescan of all LsAgent assets at once instead of having to access individual assets to clear ini files? We have a discrepancy where some assets are not reporting even though they have LsAgent installed. The LsAgent list has the correct number of assets assigned, around 1800, but only 1400 or so are showing up as scanned. I can easily run a scan using Ls Classic, but this only works for assets on the company domain. Right now I do not see a way to force Ls to scan LsAgent assets.

David_GF
Lansweeper Tech Support
Lansweeper Tech Support

@rinks It is not possible to force a LsAgent rescan of multiple assets. We recommend reaching out to our support team to troubleshoot this issue.

How to contact support?

Make sure to add screenshots and the GatherLogs output file so our SME's can start investigating the issue straight away. 

Using the GatherLogs tool.

Jacob_H
Lansweeper Employee
Lansweeper Employee

Here's my new Pro-Tip on using powershell and automating clearing out the .ini dates and restarting the service to initiate a rescan, and instructions on how to deploy/schedule with a GPO:  Schedule LsAgent to Run at User Logon - Lansweeper

FrodeD
Engaged Sweeper
Here is a freebie for those that prefer to use Powershell to reset the LastScan, and LastSent timestamps in the ini file. We have been using this via 'Run Script' in SCCM with success, to batch run a fresh LS scan from several computers or a whole collection.
 
As always test it properly before you run anything in your own environment.
 
# -----------------------------------------------------------------------------------------------------
 
# Define the function to convert FileTime to DateTime, based upon tics from January 1st year 1
function Convert-FileTimeToDateTime
{
param (
[Parameter(Mandatory = $true)]
[int64]$FileTime
)
 
# Create a DateTime object for the start date
$StartDate = New-Object System.DateTime(0001, 1, 1, 0, 0, 0)
 
# Add the FileTime (in ticks) to the start date
$DateTime = $StartDate.AddTicks($FileTime)
 
return $DateTime
}
 
# Define the function to convert DateTime back to FileTime, based upon tics from January 1st year 1
function Convert-DateTimeToFileTime
{
param (
[Parameter(Mandatory = $true)]
[DateTime]$DateTime
)
 
# Create a DateTime object for the start date
$StartDate = New-Object System.DateTime(0001, 1, 1, 0, 0, 0)
 
# Calculate the difference in ticks between the DateTime and the start date
$FileTime = $DateTime.Ticks - $StartDate.Ticks
 
return $FileTime
}
 
# Define the path to the INI file
$IniFilePath = 'C:\Program Files (x86)\LansweeperAgent\LsAgent.ini'
 
if (Test-Path $IniFilePath -PathType Leaf)
{
Add-Type -AssemblyName Microsoft.VisualBasic
 
Stop-Service LansweeperAgentService -Force
Start-Sleep -Seconds 5
 
 
# Read the INI file into an array of lines
$IniFileLines = Get-Content -Path $IniFilePath
 
# Find the lines with LastScan and LastSent values
$LastScanLine = $IniFileLines | Where-Object { $_ -match '^LastScan=' }
$LastSentLine = $IniFileLines | Where-Object { $_ -match '^LastSent=' }
 
# Extract the FileTime values from these lines and convert them to int64 type if possible
$OldLastScan = [int64]$($LastScanLine.Split('=')[1])
$OldLastSent = [int64]$($LastSentLine.Split('=')[1])
 
# If LastScan or LastSent is empty, use the current date as a fallback
# Convert values from FileTime to DateTime format if read from the ini file
if ($OldLastScan -eq 0) { $LastScan = Get-Date; }
else { $LastScan = Convert-FileTimeToDateTime -FileTime $OldLastScan }
if ($OldLastSent -eq 0) { $LastSent = Get-Date; }
else { $LastSent = Convert-FileTimeToDateTime -FileTime $OldLastSent }
 
# Subtract 8 hours 15 minutes from LastScan and 8 hours from LastSent
$NewLastScan = $LastScan.AddHours(-8).AddMinutes(-15)
$NewLastSent = $LastSent.AddHours(-8)
 
# Convert these DateTime values back to FileTime format
$NewLastScan = Convert-DateTimeToFileTime -DateTime $NewLastScan
$NewLastSent = Convert-DateTimeToFileTime -DateTime $NewLastSent
 
# Replace the old values with the new ones in the INI file lines
$IniFileLines = $IniFileLines -replace "^LastScan=$($LastScanLine -replace '^LastScan=', '')", "LastScan=$NewLastScan"
$IniFileLines = $IniFileLines -replace "^LastSent=$($LastSentLine -replace '^LastSent=', '')", "LastSent=$NewLastSent"
 
# Write these modified lines back to the INI file
Set-Content -Path $IniFilePath -Value $IniFileLines -force -PassThru
 
# not needed ? Set timestamp on the ini file back two days
$(Get-Item "$IniFilePath").lastwritetime = $(Get-Date).adddays(-2)
 
Start-Sleep -Seconds 5
Start-Service LansweeperAgentService
}

 

New to Lansweeper?

Try Lansweeper For Free

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

Try Now