I don't know if I understood your problem I need to to automate some tasks basing on the Lansweeper assets.Īt its basics, I need to query and filter lansweeper assets and perform some tasks on each filtered asset. TT $SQL |import-database -database $db_x -tablename LSU #Sends the results of the query to the sqllite db using import-db - creates LSU table $hld = get-sql -MsSQLserver -connection "Server= Integrated Security=true Initial Catalog=lansweeperdb ApplicationIntent=ReadOnly" -Session TT #queries the lansweeper db defined in the connection string session stored in "TT" $db_x = get-database #creates an in-memory db using ReallySimpleDatabase (see docs for using an on-disk db) (tblAssets.Uptime Is Not Null And tblAssets.Domain = 'OTHERDOMAIN' And Where (tblAssets.Lastseen > GetDate() - 30 And tblAssets.Domain = 'OURDOMAIN'Īnd tblAssets.Lasttried > GetDate() - 45) Or Left Join tblMacOSInfo On tblAssets.AssetID = tblMacOSInfo.AssetID Left Join tblLinuxSystem On tblAssets.AssetID = tblLinuxSystem.AssetID Inner Join tblState On tblState.State = tblAssetCustom.State Inner Join tsysIPLocations On tsysIPLocations.LocationID = tblAssets.LocationID Inner Join tsysAssetTypes On tsysAssetTypes.AssetType = tblAssets.Assettype Inner Join tblAssetCustom On tblAssets.AssetID = tblAssetCustom.AssetID Left Join tsysOS On tsysOS.OScode = tblAssets.OScode #Grabs all assets in lansweeper with usernames definedĬonvert(nvarchar(10),Ceiling(Floor(Convert(integer,tblAssets.Uptime) / 3600 /Ĭonvert(nvarchar(10),Ceiling(Floor(Convert(integer,tblAssets.Uptime) / 3600 %Ĭonvert(nvarchar(10),Ceiling(Floor(Convert(integer,tblAssets.Uptime) % 3600 /Ħ0))) + ' minutes' As UptimeSinceLastReboot,Ĭoalesce(tsysOS.OSname, tblLinuxSystem.OSRelease, tblMacOSInfo.SystemVersion) You could easily change the way it is used. That $var is a ReallySimpleDatabase in-memory db. The way I use this is to call the function and assign the results to a $var. The get-sql module allows me make queries and the ReallySimpleDatabase allow me to move the results into an in-memory database for further queries. I use a couple components to make this work. I've been able to query lansweeper from powershell and have integrated it into several scripts.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |