‎01-09-2021 05:52 PM
‎05-23-2022 08:15 PM
get-sqlmodule allows me make queries and the ReallySimpleDatabase allow me to move the results into an in-memory database for further queries. Here is some sample code
function Build-LSInfo {
#Grabs all assets in lansweeper with usernames defined
#stored in sqlite db
$sql = @"
Select Top 1000000 tblAssets.AssetID,
tblAssets.AssetName,
Convert(nvarchar(10),Ceiling(Floor(Convert(integer,tblAssets.Uptime) / 3600 /
24))) + ' days ' +
Convert(nvarchar(10),Ceiling(Floor(Convert(integer,tblAssets.Uptime) / 3600 %
24))) + ' hours ' +
Convert(nvarchar(10),Ceiling(Floor(Convert(integer,tblAssets.Uptime) % 3600 /
60))) + ' minutes' As UptimeSinceLastReboot,
tblAssets.Lastseen,
tblAssets.Username,
tblAssets.IPAddress,
tblAssetCustom.Manufacturer,
tblAssetCustom.Model,
Coalesce(tsysOS.OSname, tblLinuxSystem.OSRelease, tblMacOSInfo.SystemVersion)
As OS
From tblAssets
Left Join tsysOS On tsysOS.OScode = tblAssets.OScode
Inner Join tblAssetCustom On tblAssets.AssetID = tblAssetCustom.AssetID
Inner Join tsysAssetTypes On tsysAssetTypes.AssetType = tblAssets.Assettype
Inner Join tsysIPLocations On tsysIPLocations.LocationID = tblAssets.LocationID
Inner Join tblState On tblState.State = tblAssetCustom.State
Left Join tblLinuxSystem On tblAssets.AssetID = tblLinuxSystem.AssetID
Left Join tblMacOSInfo On tblAssets.AssetID = tblMacOSInfo.AssetID
Where (tblAssets.Lastseen > GetDate() - 30 And tblAssets.Domain = 'OURDOMAIN'
And tblAssets.Lasttried > GetDate() - 45) Or
(tblAssets.Uptime Is Not Null And tblAssets.Domain = 'OTHERDOMAIN' And
tblState.Statename = 'Active')
Order By tblAssets.Uptime Desc,
tblAssets.AssetName,
tblAssets.IPNumeric
"@
$db_x = $null
$db_x = get-database #creates an in-memory db using ReallySimpleDatabase (see docs for using an on-disk db)
#queries the lansweeper db defined in the connection string; session stored in "TT"
$hld = get-sql -MsSQLserver -connection "Server=lansweeper.myco.com;Integrated Security=true;Initial Catalog=lansweeperdb;ApplicationIntent=ReadOnly" -Session TT
#Sends the results of the query to the sqllite db using import-db - creates LSU table
TT $SQL |import-database -database $db_x -tablename LSU
#$db_x = TT $SQL
#closes the session TT
TT -close
#returns the in-memory db
return $db_x
}
‎01-23-2022 10:48 PM
‎01-26-2021 01:48 PM
‎01-20-2021 12:34 PM
SubnetJO wrote:
Goodmorning
I need to to automate some tasks basing on the Lansweeper assets.
At its basics, I need to query and filter lansweeper assets and perform some tasks on each filtered asset.
‎01-24-2021 07:18 PM
ufficioced wrote:SubnetJO wrote:
Goodmorning
I need to to automate some tasks basing on the Lansweeper assets.
At its basics, I need to query and filter lansweeper assets and perform some tasks on each filtered asset.
I don't know if I understood your problem
You could use "deploy package" in Lansweeper web console: create a deploy package with the configuration you need and then a report filtering the right assets
in the report's asset list you can deploy the package to the assets
let me know, regards
‎01-26-2021 08:24 AM
SubnetJO wrote:
So, since my scripts are powershell, my question is: how can I query Lansweeper by powershell?
...
Is there any programmatical way to query Lansweeper, without querying the undergoing database directly, of course
Experience Lansweeper with your own data. Sign up now for a 14-day free trial.
Try Now