Pro Tips with Esben #30
Lansweeper’s actions are something that is rarely talked about. But they have the potential to perform very useful actions on your assets remotely. Today we will look at how you can use actions to get a disk usage visualization of your assets.
Custom actions have long been in Lansweeper. They allow you to perform basic actions on your assets like a ping, traceroute, reboot, and more. However, you can create your own custom actions too to perform custom actions or run custom scripts on remote assets. It’s not so different from deployment, aside from the fact that here we’re talking about actions on individual assets, not in bulk. With the action we are creating today, you’ll be able to visualize your disk’s usage.
Running Custom Actions
Before we create the custom actions, it is important to ensure you can actually run actions in Lansweeper. To do this you’ll need to download and configure a browser extension so that you can run actions. You can find all the info you need in the custom actions knowledgebase article.
SpaceSniffer and Script
SpaceSniffer is a freeware computer disk space analyzer from Uderzo Software. It uses a treemap to visualize disk usage. You can download Spacesniffer and place in it your Lansweeper actions folder (C:Program Files (x86)LansweeperActions).
The script that we will be using is one I made myself (admittedly with help from StackOverflow). There are multiple ways you could run SpaceSniffer as an action, but using this script, you’ll run it as an administrator, which is needed for SpaceSniffer to access some disk areas. This script also needs to be saved in your Lansweeper actions folder. You can download it here.
You will need to adjust the script to point it to your Lansweeper server and the SpaceSniffer.exe location. First, you’ll see the following line in the script that you’ll need to adjust:
Start-Process "\uvmtst-esbenCProgram Files (x86)LansweeperActionsSpaceSniffer.exe"
Optionally, if you want to visualize a partition that isn’t the default C partition, you’ll need to adjust the c$ in the following as well:
-ArgumentList "scan \$smartnamec$"
Creating the Custom Action
Now that we have all the files in place, the only thing left to do is create the custom action in ConfigurationAsset Pages
. After the Action field, you can enter the following:
powershell -noprofile -ExecutionPolicy bypass -command {actionpath}spacesniffer.ps1 -smartname {computer}
Once created, you’ll find the action on the left-hand side of your web console when you’re on an asset.
Alternative Custom Action
If you don’t want to run SpaceSniffer as an admin, you don’t need the script and can simply create an action with the following action:
{actionpath}spacesniffer.exe scan \{computer}c$
If you want to visualize a different partition, you can change the c$ to any other partition letter.