I've changed jobs, and I no longer have access to NinjaRMM. If anyone wants to take over this project, please let me know! Or just fork it and do your thing. You have my full support. This repo and module will remain for historical purposes.
A PowerShell module to interact with the NinjaRMM Public API. This currently complies with beta version 0.1.2 of the specification.
This module is available in PowerShell Gallery:
PS C:\> Install-Module NinjaRmmApi
Or, download it from here and save all of the files somewhere in your $PSModulePath
.
To get started with this module, you will need to log into your dashboard and request an API key. Write down the access key ID and the secret access key. You will not see them again!
Then, in your PowerShell session, teach it your secrets with Set-NinjaRmmSecrets
.
PS C:\> Set-NinjaRmmSecrets -AccessKeyID "TF4STGMDR4H7AEXAMPLE" -SecretAccessKey "eh14c4ngchhu6283he03j6o7ar2fcuca0example"
You will need to do this every time you start a new PowerShell session; this module does not store your keys for you! For long-term storage, consider using a password manager, sticking the keys in your $Profile
file, or using the SecretManagement module. How you do this is an exercise left to the reader.
Now that that's been done, start using their API!
You can look up customer information with the Get-NinjaRmmCustomers
cmdlet. With no arguments, it returns a list of all customers. You can also use the -CustomerID parameter to fetch a specific customer. The NinjaRMM API returns data as objects that you can parse with other PowerShell cmdlets like Format-List
and Select-Object
(and, of course, everyone's favorite, Out-GridView
!).
PS C:\> Get-NinjaRmmCustomers -CustomerID 42
id name description
-- ---- --------------
42 Deep Thought Bring a towel.
You can get devices in the same manner, by using Get-NinjaRmmDevices
. Again, your results are PowerShell objects that you can work with.
PS C:\> $myComputer = Get-NinjaRmmDevices -DeviceID 528
PS C:\> $myComputer.System | Format-List
manufacturer : Hewlett-Packard
name : RECEPTION-PC
model : HP Z400 Workstation
dns_host_name : Reception-PC
bios_serial_number : 2UA1234567
serial_number : 2UA1234567
domain : WORKGROUP
You can get and reset alerts, too:
PS C:\> $alertsToReviewLater = Get-NinjaRmmAlerts -Since 3071641
PS C:\> Reset-NinjaRmmAlert -AlertID 3071642
When you are finished, it is best practice to remove your API key from memory:
PS C:\> Reset-NinjaRmmSecrets
There is plenty of help to read. Get started with this:
PS C:\> Get-Help about_NinjaRmmApi
Neither I nor this code are in any way affiliated with, related to, or endorsed by NinjaRMM, LLC. I'm just a user. If you need support with this PowerShell module, don't go to them. Open an issue or pull request instead.
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Test anything you build with this tool.
The NinjaRMM API is under active development; thus, so is this module. Contributions are welcome!