Skip to main content

5 posts tagged with "NinjaOne"

View All Tags

· One min read

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.

About this script

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.

The script

Get-NinjaOneDuplicateDevices.ps1
#Requires -Module NinjaOne
#Requires -Version 7
[CmdletBinding()]
param (
# Returns all devices with duplicates.
[Parameter(ParameterSetName = 'All', Mandatory)]
[Switch]$All,
# Returns the duplicate devices only.
[Parameter(ParameterSetName = 'Duplicates', Mandatory)]
[Switch]$Duplicates
)

try {
$DuplicateDevices = Get-NinjaOneDevices -detailed | Group-Object { $_.system.serialNumber } | Where-Object { $_.count -gt 1 -and ($_.name -ne '$(DEFAULT_STRING)' -and $_.name -ne 'Default string') }
if ($All) {
$Output = $DuplicateDevices | ForEach-Object { $_ | Select-Object -ExpandProperty group | Sort-Object $_.lastContact }
} elseif ($Duplicates) {
$Output = $DuplicateDevices | ForEach-Object { $_ | Select-Object -ExpandProperty group | Sort-Object $_.lastContact | Select-Object -First 1 -Property id, lastContact, @{ name = 'serialNumber'; expression = { $_.system.serialNumber } } }
}
if ($Output) {
return $Output
} else {
Write-Warning 'No duplicate devices found or an unanticipated error occurred.'
}
} catch {
Write-Error 'Please ensure the NinjaOne PowerShell module is correctly installed and you have run the "Connect-NinjaOne" command and connected to NinjaOne.'
exit 1
}

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.

If you want all devices with duplicates:

Get-NinjaOneDuplicateDevices -All

or just the older duplicated devices:

Get-NinjaOneDuplicateDevices -Duplicates

· 6 min read

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.

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.

· 5 min read

Background information

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.

· 4 min read

This post uses code from CyberDrain

Click the link below to check out the original post on CyberDrain.com and support Kelvin's fantastic work for the MSP community.

About this script

So firstly, if you haven't already, hit the giant orange button above to read the original blog post on CyberDrain.com to understand what this script is doing!

The problem with NinjaOne

Many, if not most RMM platforms can run a script to monitor system state. NinjaOne is no different here - but there's a subtle irregularity in their approach that makes this complicated.

Most RMM platforms let you extract the contents of a variable from the script you run as a monitor - Ninja doesn't. It can read from the output of the script but that's all.

The fix

This Script Has Been Updated

This script was updated after being published, if you're using it please compare the version you have with the version available here.