r/Lansweeper • u/deanm11345 • Jul 12 '19
Lansweeper-PS Modules
TL;DR: Made some Powershell modules for querying LS data about assets and users. Hopefully it doesn't suck, view my Github here or install Lansweeper-PS from PSGallery and tell me what you think. Also if you can do it better than me, please contact me to contribute to the project.
Hey guys, I posted earlier this week wondering if there were any Powershell modules available to interact with the data in LS for automation purposes. After like....3 people seemed interested I decided to devote the week to learning the best way to create/publish the modules. This module uses dbatools (a nice little set of modules for working with SQL) to query the SQL server behind LS and return an object with all properties found for any given user/computer. Please view the Github readme for the brief requirements.
I am super new to Github and publishing to PSGallery, so any help is appreciated. If anybody is interested in contributing still please let me know and I can add you as a contributor on Github. TBH I've never made anything "for the community" before so I am just hoping it can be used and added to, honestly. Below are some screenshots.



3
u/MadBoyEvo Jul 12 '19
Great work. A couple of tips
I'm wondering if you should maybe work on the SQL part. You're doing a lot of joins on PowerShell from the tables which probably isn't the best, efficient way to do it. You may want to write a single SQL query with JOINS and readjust that into PS Object. Will save you some PowerShell work, will be much faster.
You may want to split your module into Private/Public folder at some point and build on that. And then when publishing to PSGallery you just merge that in. I could probably show you how I publish my modules with another PowerShell module I wrote and it's effortless but it makes things easy to develop (as each function is in a separate file)