r/Lansweeper • u/deanm11345 • Jul 31 '19
Lansweeper & Powershell
I've put together some Powershell modules to work with LS and return asset information in the form of an object. The SQL Server behind Lansweeper is queried with dbatools and the result is a returned as an object with all the assets' information stored as properties. There's some code examples on the Github, as well as a screenshot of the output below. https://github.com/marcus-dean/Lansweeper-PS
Posting again after another a few weeks ago when I asked if anyone would be interested in the idea. I've finally put together a much more polished (re: not awful) example of what I think this could look like, and wanted to post here to hopefully attract some users/input/critique.
Example 1
For a complete look at our asset we use the Get-LSComputerObject. This cmdlet queries different tables that hold more pieces of information about a computer. This will take an AssetName or an AssetID as input.
Get-LSComputerObject -AssetName "Marcus-Laptop" -SQLInstance "SVR3-SQL"
Example 2
But let's say that we only have a computer's serial number, and we want to know the FQDN. Let's use Get-LSAssetCustom to match an AssetID to the serial number, and then look up that AssetID in Get-LSComputerObject.
$MyID = (Get-LSAssetCustom -SerialNumber "C17QC073FVH3" -SQLInstance "SVR3-SQL").AssetID
Get-LSComputerObject -AssetID $MyID -SQLInstance "SVR3-SQL" | Select FQDN
| Function | Table Queried |
|---|---|
| Get-LSAsset | tblAssets |
| Get-LSAssetCustom | tblAssetCustom |
| Get-LSADComputer | tblADComputers |
| Get-LSUser | tblUsers |
| Get-LSLinuxSystem | tblLinuxSystem |
| Get-LSDisks | tblDiskDrives |
| Get-LSLinuxVolumes | tblLinuxVolumes |
| Get-LSWindowsSoftware | tblAssets, tblAssetCustom, tblSoftware, tblSoftwareUni, tsysOS |
| Get-LSMacSoftware | tblAssets, tblAssetCustom, tlbMacApplications, tblSoftwareUni, tblMacOsInfo |
| Get-LSComputerObject | tblAssets, tblAssetCustom, tblCPLogonInfo, tblNetwork, tblNetworkAdapter, tblEncryptableDisk, tblProxy |