This script uses an undocumented Microsoft 365 API to check the latest version of Microsoft Office / 365 Apps and compares it to the installed version. It then sets a custom field in NinjaOne to indicate whether the latest security release (if there is one) is installed. It also sets fields to indicate the channel, installed version, update status and a card containing more detailed information.
Thanks to:
- The entire NinjaOne community on the NinjaOne Discord for the inspiration and support.
- David Szpunar for his efforts on various M365 / Office apps scripts.
- Kelvin Tegelaar for his prior M365 / Office apps scripts.
This article uses an undocumented API to check the latest version of Microsoft Office / 365 Apps. This API is subject to change without notice and may stop working at any time. Use at your own risk.
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 one role custom field for devices with the Windows Desktop or Laptop and/or Windows Server role, note that we've customised slightly the autogenerated machine name here, if you use the default adjust the field name in the script appropriately.
Field Label | Field Name | Field Type | Description |
---|---|---|---|
M365 Apps Installed Version | officeInstalledVersion | Text | The installed version of Microsoft Office / 365 Apps. |
M365 Apps Channel | officeChannel | Text | The channel of Microsoft Office / 365 Apps. |
M365 Apps Update Status | officeUpdateStatus | Text | The update status of Microsoft Office / 365 Apps. |
M365 Apps Secure | officeSecure | Checkbox | Whether the latest security (or other) release is installed. |
M365 Apps Detail | officeDetail | WYSIWYG | A card containing more detailed information about Microsoft Office / 365 Apps. |
The Script
loading...
The Results
We run this script daily and have a corresponding monitor setup to check whether M365 Apps Secure is checked. If it's not, we get an alert and can investigate further. This script has already helped us identify a few devices that were not updating correctly.