This post uses code from CyberDrain
This post draws on multiple posts, click the link below to check out CyberDrain.com and support Kelvin's fantastic work for the MSP community.
You will find more excellent uses for NinjaOne custom fields on the Dojo, on Stephen Murphy's blog and on Luke Whitelock's blog.
Custom fields are a great way to store arbitrary data from your devices in NinjaOne. In this post I will explore a few examples, some using code from CyberDrain, which store data in NinjaOne custom fields.
This post was updated on 2022/12/22 to add a new script to run a speedtest on a device and store the results in NinjaOne.
Battery Health
Creating Fields
- Role Custom Fields are custom fields that are specific to a device role.
- Global Custom Fields are custom fields that are applicable to all devices and/or to a location and/or organisation
When you create your custom field you need to make sure that you set the Scripts permission to ensure that you can read or write to the field from your scripts - as appropriate for the script you're using.
We're adding seven role custom fields for devices with the Windows Laptop role:
Field Name | Field Type | Description |
---|---|---|
Has Batteries | Checkbox | Whether the device has batteries |
Battery Identifier | Text | The ID of the battery being reported on. |
Battery Design Capacity | Integer | The original design capacity of the laptop's battery. |
Battery Full Charge Capacity | Integer | The current fully charged capacity of the laptop's battery. |
Battery Health Percent | Integer | The current percentage of battery health. |
Battery Cycle Count | Integer | The number of times the battery has been cycled. That is drained fully and charged. |
Additional Battery | Checkbox | The system has an additional battery, only the first is reported in the fields above. |
The Script
This script was updated after being published, if you're using it please compare the version you have with the version available here.
This script was last updated on 2022/03/26.
This script accepts a single parameter to set the data storage directory for the script. This is where the script will store the battery information it gathers. The script will create the directory if it doesn't exist. The default is C:\RMM\Data
use parameter -OutputPath
to override.
loading...
Source: https://www.cyberdrain.com/monitoring-with-powershell-monitoring-battery-health/
The Results
You can set this up to run on a schedule - we run this script monthly to keep up-to-date battery information in NinjaOne.
Domain Join Status
Creating Fields
- Role Custom Fields are custom fields that are specific to a device role.
- Global Custom Fields are custom fields that are applicable to all devices and/or to a location and/or organisation
When you create your custom field you need to make sure that you set the Scripts permission to ensure that you can read or write to the field from your scripts - as appropriate for the script you're using.
We're adding three role custom fields for devices with the Windows Laptop role:
Field Name | Field Type | Description |
---|---|---|
Domain Join Status | Drop-down | The current domain join status of the device. |
Domain Name | Text | The name of the currently joined AD domain. |
Tenant Name | Text | The name of the currently joined Azure AD tenant. |
The domain join status field should be configured with the following option values:
- Azure AD Domain
- AD Domain
- Hybrid Azure AD/AD Domain
- On-premise DRS
- No Domain
Options
We've created a dropdown field for this script, we can't set the options by name with these - so first we need to find out how NinjaOne wants us to give the selected option. To do that we're going to open a PowerShell session to any device in the role that has the field assigned and run:
Set-ExecutionPolicy -Scope Process -ExecutionPolicy RemoteSigned
Import-Module NJCliPSh
Ninja-Property-Options domainJoinStatus
This will print a list that looks something like this:
1989092a-1ae0-4e6e-b274-50ea9618d436=Azure AD Domain
53745d33-fd5e-4c7d-bfd5-fea174a46781=No Domain
bb4c5215-ead7-47a3-8f36-f711c81580ce=On-premises DRS
c23486e9-49eb-4acb-8f9d-7f5d8711c284=AD Domain
c6e7ef80-68a1-4591-8055-5cee585f4f79=Hybrid Azure AD/AD Domain
When we want to pass the option to the field we need to use the GUID - for example 1989092a-1ae0-4e6e-b274-50ea9618d436
for Azure AD Domain.
The Script
### Inline Comments
'<MARKED STRINGS>'
This script was updated after being published, if you're using it please compare the version you have with the version available here.
This script was last updated on 2022/05/25.
loading...
The Results
You can set this up to run on a schedule - we run this script monthly to keep up-to-date domain information in NinjaOne.
Autopilot Hardware Identifier
Creating Fields
- Role Custom Fields are custom fields that are specific to a device role.
- Global Custom Fields are custom fields that are applicable to all devices and/or to a location and/or organisation
When you create your custom field you need to make sure that you set the Scripts permission to ensure that you can read or write to the field from your scripts - as appropriate for the script you're using.
Make sure when creating the custom field below that you set the character limit for the field to allow over 4000 characters using the "Advanced Settings" link on the field creation/edit page.
We're adding one role custom field for devices with the Windows Desktops and Laptops role:
Field Name | Field Type | Description |
---|---|---|
Autopilot HWID | Secure | The autopilot hardware identifier. |
The Script
loading...
The Results
We run this after hardware changes or post onboarding.
Wireless LAN Monitoring
Creating Fields
- Role Custom Fields are custom fields that are specific to a device role.
- Global Custom Fields are custom fields that are applicable to all devices and/or to a location and/or organisation
When you create your custom field you need to make sure that you set the Scripts permission to ensure that you can read or write to the field from your scripts - as appropriate for the script you're using.
We're adding three role custom fields for devices with the Windows Desktops and Laptops role:
Field Name | Field Type | Description |
---|---|---|
WLAN Disconnect Reasons | Multi-line | A list of the WLAN disconnect reasons with frequency. JSON |
WLAN Failures | Integer | The number of WLAN failures in the report. |
WLAN Warnings | Integer | The number of WLAN warnings in the report. |
The Script
loading...
The Results
You can set this up to run on a schedule - we run this script twice daily.
Windows 11 Readiness
Creating Fields
- Role Custom Fields are custom fields that are specific to a device role.
- Global Custom Fields are custom fields that are applicable to all devices and/or to a location and/or organisation
When you create your custom field you need to make sure that you set the Scripts permission to ensure that you can read or write to the field from your scripts - as appropriate for the script you're using.
We're adding two role custom fields for devices with the Windows Desktops and Laptops role:
Field Name | Field Type | Description |
---|---|---|
Windows 11 Capable | Checkbox | Whether the device is Windows 11 capable as determined by our checks. |
Windows 11 Readiness | WYSIWYG | The details checked to determine Windows 11 compatibility. |
The Script
This script was updated after being published, if you're using it please compare the version you have with the version available here.
This script was last updated on 2024/05/16.
loading...
Thanks to @gavsto for invaluable input on a couple of the checks in here - he's helped make them more robust and accurate.
The script's detailed output has changed and will now show two metrics related to Secure Boot. Previously it showed in SecureBootSuitable
whether the state of Secure Boot was suitable for Windows 11 installation. This has been enhanced with a new SecureBootPossible
metric which will show whether it's likely that Secure Boot can be enabled. A "No" to both metrics will indicate that Secure Boot is not enabled or not capable of being enabled and thus the device is not Windows 11 capable. A "Yes" to SecureBootPossible
indicates that Secure Boot can likely be enabled and that this should be done to make the device Windows 11 capable.
The Results
We ran this as a one-off job to evaluate our managed estate.
Limitations
This script won't detect compatible devices if the TPM is not enabled in the BIOS. It may not detect all compatible devices. This script may not accurately detect Secure Boot capability on all devices.
Windows OS Support Status
Creating Fields
- Role Custom Fields are custom fields that are specific to a device role.
- Global Custom Fields are custom fields that are applicable to all devices and/or to a location and/or organisation
When you create your custom field you need to make sure that you set the Scripts permission to ensure that you can read or write to the field from your scripts - as appropriate for the script you're using.
We're adding two role custom fields for devices with the Windows Desktops and Laptops and the Windows Server role:
Field Name | Field Type | Description |
---|---|---|
Windows Active Support | Checkbox | Whether the OS version is supported for feature / quality updates. |
Windows Security Support | Checkbox | Whether the OS version is supported for security updates. |
The Script
Thanks to Khristos from the MSP Geek community for keeping an eye on EndOfLife.Date's endlessly changing property for holding the Windows build...
This script was updated after being published, if you're using it please compare the version you have with the version available here.
This script was last updated on 2023/01/26.
loading...
The Results
We run this on a schedule so it runs just after our OS patching applies.
Limitations
Won't work with Insider/Preview versions - hasn't been tested on Windows 7 / 8 or 8.1. Has been tested on Server 2012 R2, 2022 and Windows 10 and 11.
SpeedTest (LibreSpeed)
Creating Fields
- Role Custom Fields are custom fields that are specific to a device role.
- Global Custom Fields are custom fields that are applicable to all devices and/or to a location and/or organisation
When you create your custom field you need to make sure that you set the Scripts permission to ensure that you can read or write to the field from your scripts - as appropriate for the script you're using.
We're adding three role custom fields for devices with the Windows Desktops and Laptops and the Windows Server role:
Field Name | Field Type | Description |
---|---|---|
Server Used | Text | Which server was used for the last speedtest run. |
Download Speed | Decimal | The download speed from the last speedtest run in megabits per second. |
Upload Speed | Decimal | The upload speed from the last speedtest run in megabits per second. |
The Script
This script seems to have some issues where the librespeed-cli will return null
for tests intermittently - this was due to service issues with LibreSpeed themselves. An alternative version using the Ookla speedtest CLI is available below.
This script was updated after being published, if you're using it please compare the version you have with the version available here.
This script was last updated on 2022/12/31.
loading...
Parameters
You can pass a few different parameters to this script to tune it's behaviour. These are:
Parameter Name | Type | Description |
---|---|---|
LibreSpeedEXEPath | String | The path to the LibreSpeed executable. Defaults to C:\RMM\Bin\ |
NoUpdate | Switch | If specified, the script will not attempt to update or download LibreSpeed. |
ForceUpdate | Switch | If specified, the script will download LibreSpeed even if it's already up to date. |
CLISwitches | String | A string of switches to pass to the LibreSpeed CLI. Defaults to --json . |
For documentation on the CLI switches available see the LibreSpeed CLI documentation.
The Results
In this screenshot we've added a separator and a nice custom title with an emoji to make it look a bit nicer.
⏱️SPEEDTEST
We run this on demand when we want to refresh information on the device - we don't run it on a schedule at present.
Limitations
Requires the ability to run the LibreSpeed CLI tool on the device. The script can fetch the latest version and will do so automatically.
SpeedTest (Ookla Speedtest)
Creating Fields
- Role Custom Fields are custom fields that are specific to a device role.
- Global Custom Fields are custom fields that are applicable to all devices and/or to a location and/or organisation
When you create your custom field you need to make sure that you set the Scripts permission to ensure that you can read or write to the field from your scripts - as appropriate for the script you're using.
We're adding three role custom fields for devices with the Windows Desktops and Laptops and the Windows Server role:
Field Name | Field Type | Description |
---|---|---|
Server Used | Text | Which server was used for the last speedtest run. |
Download Speed | Decimal | The download speed from the last speedtest run in megabits per second. |
Upload Speed | Decimal | The upload speed from the last speedtest run in megabits per second. |
The Script
loading...
Parameters
You can pass a few different parameters to this script to tune it's behaviour. These are:
Parameter Name | Type | Description |
---|---|---|
OoklaSpeedtestURI | String | The URI to the Ookla Speedtest CLI. Defaults to the 1.2.0 version current when written. |
OoklaSpeedtestEXEPath | String | The path to the Ookla Speedtest executable. Defaults to C:\RMM\Bin\ |
NoUpdate | Switch | If specified, the script will not attempt to update or download Ookla Speedtest. |
ForceUpdate | Switch | If specified, the script will download Ookla Speedtest even if it's already up to date. |
CLISwitches | String | A string of switches to pass to the Ookla Speedtest CLI. Defaults to --format=json --accept-license --accept-gdpr . |
For documentation on the CLI switches available you should download the latest version of the CLI and check out the speedtest.md file in the Zip or run speedtest.exe --help
.
The Results
In this screenshot we've added a separator and a nice custom title with an emoji to make it look a bit nicer.
⏱️SPEEDTEST
We run this on demand when we want to refresh information on the device - we don't run it on a schedule at present.
Limitations
Requires the ability to run the Ookla Speedtest CLI tool on the device. The script cannot automatically determine the latest version at this time - please pass an updated URL if you wish to use a later version before the script is updated.