To create a custom field in NinjaOne go to Administration > Devices and select either Role Custom Fields or Global Custom Fields then select Add.
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
Make sure you add the fields to the roles you want to use them in at Administration > Devices > Roles (for role custom fields).
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
Driver Update: Reboot Required
Checkbox
Whether the latest driver update run requires a reboot to finalise.
Driver Update: Last Run
Date/Time
The date and time the driver update script last ran successfully.
Driver Update: Number Installed on Last Run
Integer
The number of driver updates installed on last script run.
You can set this up to run on a schedule - we run this script immediately on machine onboarding and then every 7 days on a Tuesday. This doesn't always have anything to do as our Windows Update run usually handles these updates, but it's a good way to ensure that we're always up to date with the latest drivers from Microsoft Update.
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.
To create a custom field in NinjaOne go to Administration > Devices and select either Role Custom Fields or Global Custom Fields then select Add.
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
Make sure you add the fields to the roles you want to use them in at Administration > Devices > Roles (for role custom fields).
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.
Ninja have confirmed that they are working on native functionality which will replace this script. Stay tuned to Ninja's release notes on the [NinjaOne Dojo](https://ninjarmm.zendesk.com) for more information.
This Script Was Updated
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.
To create a custom field in NinjaOne go to Administration > Devices and select either Role Custom Fields or Global Custom Fields then select Add.
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
Make sure you add the fields to the roles you want to use them in at Administration > Devices > Roles (for role custom fields).
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:
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:
This script requires user input, whether in the form of variables, parameters or edits to the script itself before you can run it. Areas where you need to provide input will be indicated with:
### Inline Comments
and / or
'<MARKED STRINGS>'
Parameters will be indicated before the script block.
This Script Was Updated
This script was updated after being published, if you're using it please compare the version you have with the version available here.
To create a custom field in NinjaOne go to Administration > Devices and select either Role Custom Fields or Global Custom Fields then select Add.
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
Make sure you add the fields to the roles you want to use them in at Administration > Devices > Roles (for role custom fields).
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.
"Field length"
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:
To create a custom field in NinjaOne go to Administration > Devices and select either Role Custom Fields or Global Custom Fields then select Add.
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
Make sure you add the fields to the roles you want to use them in at Administration > Devices > Roles (for role custom fields).
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
To create a custom field in NinjaOne go to Administration > Devices and select either Role Custom Fields or Global Custom Fields then select Add.
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
Make sure you add the fields to the roles you want to use them in at Administration > Devices > Roles (for role custom fields).
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.
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.
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.
To create a custom field in NinjaOne go to Administration > Devices and select either Role Custom Fields or Global Custom Fields then select Add.
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
Make sure you add the fields to the roles you want to use them in at Administration > Devices > Roles (for role custom fields).
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.
To create a custom field in NinjaOne go to Administration > Devices and select either Role Custom Fields or Global Custom Fields then select Add.
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
Make sure you add the fields to the roles you want to use them in at Administration > Devices > Roles (for role custom fields).
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.
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
This script was updated after being published, if you're using it please compare the version you have with the version available here.
To create a custom field in NinjaOne go to Administration > Devices and select either Role Custom Fields or Global Custom Fields then select Add.
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
Make sure you add the fields to the roles you want to use them in at Administration > Devices > Roles (for role custom fields).
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.
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.
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.
To create a custom field in NinjaOne go to Administration > Devices and select either Role Custom Fields or Global Custom Fields then select Add.
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
Make sure you add the fields to the roles you want to use them in at Administration > Devices > Roles (for role custom fields).
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 going to create one role custom field for devices with the Windows Desktop or Windows Laptop role:
Field Name
Field Type
Description
Detailed AV Status
Multi-Line
Output for each configured AV on the system including name and status information.
This script won't work on Windows Server operating systems as they lack a CIM or WMI interface to the Windows Security Center which allows us to easily programmatically query the AV status.
The code in this script was inspired by functionality in the CyberDrain Improved Partner Portal (CIPP). Need to manage M365 tenants - CIPP is a fantastic open-source solution for M365 management for single tenants and Microsoft CSP Partners alike.
In my quest to stop having to use Windows Sandbox or VMs to access Exchange Online via PowerShell (we have WinRM basic auth disabled) I've been looking at solutions using the Exchange Online REST API to run commands against our customer tenants. The result of my efforts is a pretty complex script that introduces a method to run any PowerShell script in the context of a set of customer tenants.
caution
You need to have configured the Secure Application Model according to the instructions linked above, you will need your SAM tokens etc accessible for this guide.
Securing Credentials in Scripts
Do not store credentials directly in scripts. You should utilise services like Azure KeyVault or other PAM solutions to secure credentials used in scripts, including this one.
Personally I find passing parameters as a HashTable (splatting) easier to read and cleaner see what's happening so that's what I'm doing to explain the parameters for the script:
Parameter Splat
$EORESTParameters = @{ PartnerTenantId = (Get-AzKeyVaultSecret-VaultName 'Homotechsual'-Name 'EORESTTenantId'-AsPlainText)# Your partner tenant id. ApplicationId = (Get-AzKeyVaultSecret-VaultName 'Homotechsual'-Name 'EORESTClientId'-AsPlainText)# Your SAM application / client id. ApplicationSecret = (Get-AzKeyVaultSecret-VaultName 'Homotechsual'-Name 'EORESTClientSecret'-AsPlainText)# Your SAM application / client secret. GraphRefreshToken = (Get-AzKeyVaultSecret-VaultName 'Homotechsual'-Name 'EORESTRefreshToken'-AsPlainText)# The Graph refresh t oken provided by the SAM app creation script. ExchangeRefreshToken = (Get-AzKeyVaultSecret-VaultName 'Homotechsual'-Name 'EORESTExchangeRefreshToken'-AsPlainText)# The Exchange refresh token provided by the SAM app creation script. UPN = '[email protected]'# The UPN of the user used to authorise your SAM tokens. IncludeTenants = @('test1.onmicrosoft.com')# Run only on the tenants listed - using the tenant's `DefaultDomainName`. This input is NOT validated. ExcludeTenants = @('test1.onmicrosoft.com')# Run on the all tenant except those listed - using the tenant's `DefaultDomainName`. }
The -ScriptBlock parameter passed to the script runs the commands given against each selected tenant's Exchange Online. You should use the Invoke-EORequest cmdlet in the script block to send commands to ExchangeOnline. For example to get mailboxes:
Before returning values we add a property to object containing the customer's tenant id. This property is called EORCustomerId and is the tenant GUID. You can use this to group results by the tenant they relate to.
I'm the author of the NinjaOne PowerShell module so when I was looking for a quick way to identify duplicate devices I turned to that module and the NinjaOne API to find a solution.
This script is a quick way to identify duplicate devices in your NinjaOne instance. It can return a full listing of all devices grouped by serial number, it can also just return the ID, last contact date and serial number for the device with the oldest last contact date.
At this time it's not possible to remove devices via the NinjaOne API so this script will only return the duplicate devices - you'll have to arrange to remove these devices manually.
Did you know, when you have a retention policy configured for OneDrive in Microsoft 365 you lose the ability to recursively delete folders. The OneDrive client often handles this by recursing through the folder tree to remove the online copies but sometimes that doesn't work and in those cases you can end up stuck with a folder tree that you would have to manually recurse to remove the offending folders by first emptying them entirely before OneDrive will let you delete them.
Well that's never going to happen ;-)
Enter PowerShell.
Required Modules
You'll need the PnP.PowerShell module for this script. Install with Install-Module 'PnP.PowerShell'
The script is looking for three parameters, an example invocation to remove a synced "Documents/PowerShell/Modules" folder in Satya Nadella's OneDrive would be:
Double the Documents
You'll notice below that the /Documents folder in the path is doubled. This is because the first folder in the OneDrive path is always /Documents then your path starts. In this example we're removing the /Documents/PowerShell/Modules folder.
The NinjaOne agent gives you the ability to customise your system tray and add things like about text, email links, a help request form, a URL and other things. Unfortunately HaloPSA doesn't currently support hooking into NinjaOne's help request form (don't worry, we're talking to NinjaOne and Halo Service Solutions about this!) so we're left with a bit of a workaround as a solution.
I've released another PowerShell module; this one is called MSGraphMail and it's a simple PowerShell Graph API email client implementation which was requested by one of our MSP customers to help with transitioning their setup from a legacy SMTP server to Microsoft 365 without redeveloping a very bespoke workflow!
HaloPSA is improving at a phenomenal rate - one of the latest enhancements relates to embedding the "customer portal" inside Teams for easier access by customers - this is early days for this enhancement to Halo and at present there isn't really a way to push this tab into customer environments... Until now!
Using the script below you can push any website as a tab to your customers' Teams environments. First a couple of configuration pre-requisites.
Do not store credentials directly in scripts. You should utilise services like Azure KeyVault or other PAM solutions to secure credentials used in scripts, including this one.
This Script Was Updated
This script was updated after being published, if you're using it please compare the version you have with the version available here.
Save yourself the headache - use the Microsoft Store on Windows 11
If you're using or managing this for Windows 11 you can now deploy Adobe Acrobat Reader DC using the Microsoft Store. This is preferable for many reasons mostly because this way of doing it with IntuneWin files is a complete pain in the ass.
In short, it's a format designed to package Windows application installers for deployment with Intune.
This post contains a script which downloads the latest version of the Adobe Reader DC installer and turns it into an IntuneWin package for Intune deployment.
I'm planning a future blog post that integrates these steps into Kelvin's module's workflow providing a single script you can use to get the latest version of Adobe Reader DC and upload it to all your customers' Intune tenants.