Skip to main content

Monitoring Microsoft Office / 365 Apps with PowerShell

· 2 min read

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:
security

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

Creating custom fields 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 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 LabelField NameField TypeDescription
M365 Apps Installed VersionofficeInstalledVersionTextThe installed version of Microsoft Office / 365 Apps.
M365 Apps ChannelofficeChannelTextThe channel of Microsoft Office / 365 Apps.
M365 Apps Update StatusofficeUpdateStatusTextThe update status of Microsoft Office / 365 Apps.
M365 Apps SecureofficeSecureCheckboxWhether the latest security (or other) release is installed.
M365 Apps DetailofficeDetailWYSIWYGA card containing more detailed information about Microsoft Office / 365 Apps.

The Script

Detect-CVE202430103.ps1
loading...

The Results

M365 Apps Fields

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.