This module syncs device information from NinjaRMM to Microsoft Intune for Autopilot enrollment. The module is currently under development and not ready for use.
This module calls the NinjaRMM API to retrieve a listing of devices. It then uploads the serial number and hardware hash to Intune via the Graph API. By default, NinjaRMM only collects a serial number from the device. To collect the hardware hash, there is a bit of configuration required within NinjaRMM itself.
The process of collecting the hardware hash relies on setting up a custom field to store the information within NinjaRMM. Additionally, a script will need to be ran on each computer that grabs the hash from the machine and saves it to your custom field in NinjaRMM. Thankfully, NinjaRMM allows you to schedule scripts to run automatically to make this a hands-off process.
- In NinjaRMM, navigate to Configuration > Devices > Role Custom Fields. Click Add in the top right corner.
- Fill out the following information and click Create.
- Label - Autopilot HWID
- Name - autopilotHwid
- Field Type - Text
- Once the next page loads, fill out the following information and click Save.
- Technician - Read Only
- Scripts - Read/Write
- The newly created field now needs assigned to a device role. Navigate to Configuration > Devices > Roles.
- Hover over Windows Desktops and Laptops and select Edit.
- Click the Add button, and select Field.
- Choose Autopilot HWID from the dropdown and click Add. Then, click Save.
At this point, you should be able to navigate to any Windows device within NinjaRMM and see the Autopilot HWID field on the Custom Fields tab. This is great and all, but now we need to populate that field.
I am going to assume that you know how to create a script in NinjaRMM. I will also assume that you know how to schedule scripts to run automatically. With all that being said, here is the script you will need to create and schedule in NinjaRMM:
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
if (-not(Get-InstalledModule PowerShellGet -ErrorAction silentlycontinue)) {
Try {
Install-PackageProvider NuGet -Force | Out-Null
Set-PSRepository PSGallery -InstallationPolicy Trusted
Install-Module PowerShellGet -Force
} Catch {
Write-Host "There was an error installing NuGet or PowerShellGet."
Exit 1
}
}
Set-ExecutionPolicy -Scope Process -ExecutionPolicy RemoteSigned -Force
Install-Script -Name Get-WindowsAutoPilotInfo -Force
$HWID = Get-WindowsAutoPilotInfo.ps1
Ninja-Property-Set autopilotHwid $HWID."Hardware Hash"
The next step is obtaining API credentials from NinjaRMM so that the tool can retrieve the device information.
- In NinjaRMM, navigate to Configuration > Integrations > API > Client App IDs. Click Add in the top right corner.
- Fill out the following information and click Save. You will be presented with a client secret upon saving. Make sure you save the client secret as there is no way to view it again.
- Application platform - API Services
- Name - NinjaRMM.Autopilot
- Scopes - Check all available options
- Allowed Grant Types - Client Credentials
- Copy and save the Client ID of the newly created NinjaRMM.Autopilot application.