
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-09-2022 11:59 AM - last edited on ‎04-01-2024 12:55 PM by Mercedes_O
Basically, I want to run an SQL to auto-populate the tblAssetCustom.Contact on what is in the Last User
Solved! Go to Solution.
- Labels:
-
Report Center
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-12-2022 12:09 PM
I've added a script below which fills the scanned AD displayname in the Contact field, if the last logged on user was an AD user and this AD user was scanned via an Active Directory User Path target.
- Keep in mind that this script will overwrite any data that is currently already stored in tblAssetCustom.Contact, to avoid that, you'd need to adjust the where clause (only select rows with empty/NULL values in that field)
- Do be careful when running scripts, make sure you've got a backup ready, just in case. Keep in mind you can no longer run scripts via the web console, this was removed to improve the security of the application. You'll need to connect to your Lansweeper database using SQL Server Management Studio or user Program Files (x86)\Lansweeper\Tools\DatabaseMaintenance.exe
https://www.lansweeper.com/kb/94/backing-up-your-installation.html
Keep in mind that joining tblADUsers to the script will likely reduce the amount of assets targeted by it. It should still cover all of your Windows computers that have had logons by AD users if you've fully scanned your AD via an AD User Path scanning target.
UPDATE tblassetcustom
SET
contact = ad.Displayname
FROM tblassetcustom
INNER JOIN tblassets a ON a.assetid = tblassetcustom.assetid
INNER JOIN tbladusers ad ON ad.username = a.username
AND ad.Userdomain = a.Userdomain;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-12-2022 12:09 PM
I've added a script below which fills the scanned AD displayname in the Contact field, if the last logged on user was an AD user and this AD user was scanned via an Active Directory User Path target.
- Keep in mind that this script will overwrite any data that is currently already stored in tblAssetCustom.Contact, to avoid that, you'd need to adjust the where clause (only select rows with empty/NULL values in that field)
- Do be careful when running scripts, make sure you've got a backup ready, just in case. Keep in mind you can no longer run scripts via the web console, this was removed to improve the security of the application. You'll need to connect to your Lansweeper database using SQL Server Management Studio or user Program Files (x86)\Lansweeper\Tools\DatabaseMaintenance.exe
https://www.lansweeper.com/kb/94/backing-up-your-installation.html
Keep in mind that joining tblADUsers to the script will likely reduce the amount of assets targeted by it. It should still cover all of your Windows computers that have had logons by AD users if you've fully scanned your AD via an AD User Path scanning target.
UPDATE tblassetcustom
SET
contact = ad.Displayname
FROM tblassetcustom
INNER JOIN tblassets a ON a.assetid = tblassetcustom.assetid
INNER JOIN tbladusers ad ON ad.username = a.username
AND ad.Userdomain = a.Userdomain;

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-16-2022 08:55 AM
I can confirm Script the worked! thanks a lot Bruce_B
