<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/">
    <channel>
        <title>Homotechsual Blog</title>
        <link>https://homotechsual.dev/</link>
        <description>Homotechsual Blog</description>
        <lastBuildDate>Fri, 29 May 2026 00:00:00 GMT</lastBuildDate>
        <docs>https://validator.w3.org/feed/docs/rss2.html</docs>
        <generator>https://github.com/jpmonette/feed</generator>
        <language>en</language>
        <copyright>Copyright © 2026 Mikey O'Toole</copyright>
        <item>
            <title><![CDATA[Intune Status Health Check with NinjaOne and PowerShell]]></title>
            <link>https://homotechsual.dev/2026/05/29/Intune-Status-Health-Check-NinjaOne</link>
            <guid>https://homotechsual.dev/2026/05/29/Intune-Status-Health-Check-NinjaOne</guid>
            <pubDate>Fri, 29 May 2026 00:00:00 GMT</pubDate>
            <description><![CDATA[A device can look healthy in NinjaOne and still have broken Intune enrollment state in the background.]]></description>
            <content:encoded><![CDATA[<p>A device can look healthy in NinjaOne and still have broken Intune enrollment state in the background.</p>
<p>This script-driven health check validates key Intune enrollment indicators and writes the results to NinjaOne custom fields so you can alert on drift quickly.</p>
<!-- -->
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="creating-fields">Creating Fields<a href="https://homotechsual.dev/2026/05/29/Intune-Status-Health-Check-NinjaOne#creating-fields" class="hash-link" aria-label="Direct link to Creating Fields" title="Direct link to Creating Fields" translate="no">​</a></h2>
<div class="theme-admonition theme-admonition-ninja admonition_Gfwi alert alert--ninja"><div class="admonitionHeading_f1Ed"><span class="admonitionIcon_kpSf"><svg data-prefix="fas" data-icon="user-ninja" class="svg-inline--fa fa-user-ninja" role="img" viewBox="0 0 448 512" aria-hidden="true"><path fill="currentColor" d="M352 128c0 70.7-57.3 128-128 128-57.2 0-105.6-37.5-122-89.3-1.1 1.3-2.2 2.6-3.5 3.8-15.8 15.8-38.8 20.7-53.6 22.1-8.1 .8-14.6-5.7-13.8-13.8 1.4-14.7 6.3-37.8 22.1-53.6 5.8-5.8 12.6-10.1 19.6-13.4-7-3.2-13.8-7.6-19.6-13.4-15.8-15.8-20.7-38.8-22.1-53.6-.8-8.1 5.7-14.6 13.8-13.8 14.7 1.4 37.8 6.3 53.6 22.1 4.8 4.8 8.7 10.4 11.7 16.1 21.3-41.2 64.3-69.4 113.8-69.4 70.7 0 128 57.3 128 128zM144 112c0 8.8 7.2 16 16 16l128 0c8.8 0 16-7.2 16-16s-7.2-16-16-16L160 96c-8.8 0-16 7.2-16 16zm-1.4 211l67 50.2c8.5 6.4 20.3 6.4 28.8 0l67-50.2c6.5-4.9 15.2-6.2 22.6-2.8 61.4 28.2 104.1 90.2 104.1 162.1 0 16.4-13.3 29.7-29.7 29.7L45.7 512c-16.4 0-29.7-13.3-29.7-29.7 0-72 42.7-134 104.1-162.1 7.4-3.4 16.1-2.1 22.6 2.8z"></path></svg></span>Creating custom fields in NinjaOne</div><div class="admonitionContent_UjKb">To create a custom field in NinjaOne go to <b>Administration <!-- -->&gt;<!-- --> Devices</b> and select either <b>Role Custom Fields</b> or <b>Global Custom Fields</b> then select <b>Add</b>.<br><br><ul><li>Role Custom Fields are custom fields that are specific to a device role.</li><li>Global Custom Fields are custom fields that are applicable to all devices and/or to a location and/or organisation</li></ul>Make sure you add the fields to the roles you want to use them in at <b>Administration <!-- -->&gt;<!-- --> Devices <!-- -->&gt;<!-- --> Roles</b> (for role custom fields).<br><br>When you create your custom field you need to make sure that you set the <b>Scripts</b> permission to ensure that you can read or write to the field from your scripts - as appropriate for the script you're using.</div></div>
<p>You can run this script without custom fields, but fields are what make it operationally useful in NinjaOne.</p>
<table><thead><tr><th>Field Label</th><th>Field Name</th><th>Field Type</th><th>Description</th></tr></thead><tbody><tr><td>Intune Enrollment Status</td><td><code>intuneEnrollmentStatus</code></td><td>Checkbox</td><td><code>true</code> when enrollment checks pass or partial-pass, <code>false</code> when not enrolled.</td></tr><tr><td>Intune Tenant ID</td><td><code>intuneTenantId</code></td><td>Text</td><td>Tenant ID discovered by <code>dsregcmd /status</code>.</td></tr><tr><td>Intune Last Sync Attempt</td><td><code>intuneLastSyncAttempt</code></td><td>Date/Time</td><td>Unix timestamp converted by NinjaOne as last known sync attempt.</td></tr><tr><td>Intune Last Sync Status</td><td><code>intuneLastSyncStatus</code></td><td>Text</td><td><code>OK</code>, <code>Error</code>, or <code>NoData</code> based on latest DM-EDP sync result event.</td></tr></tbody></table>
<p><img decoding="async" loading="lazy" alt="NinjaOne custom fields configured for Intune status monitoring" src="https://homotechsual.dev/assets/images/NinjaOneIntuneStatusCustomFields-d5f019ce71354c450299e97a03d76089.png" width="1291" height="158" class="img_ev3q"></p>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="the-script">The Script<a href="https://homotechsual.dev/2026/05/29/Intune-Status-Health-Check-NinjaOne#the-script" class="hash-link" aria-label="Direct link to The Script" title="Direct link to The Script" translate="no">​</a></h2>
<div class="theme-admonition theme-admonition-tip admonition_Gfwi alert alert--success"><div class="admonitionHeading_f1Ed"><span class="admonitionIcon_kpSf"><svg data-prefix="fas" data-icon="lightbulb" class="svg-inline--fa fa-lightbulb" role="img" viewBox="0 0 384 512" aria-hidden="true"><path fill="currentColor" d="M292.9 384c7.3-22.3 21.9-42.5 38.4-59.9 32.7-34.4 52.7-80.9 52.7-132.1 0-106-86-192-192-192S0 86 0 192c0 51.2 20 97.7 52.7 132.1 16.5 17.4 31.2 37.6 38.4 59.9l201.7 0zM288 432l-192 0 0 16c0 44.2 35.8 80 80 80l32 0c44.2 0 80-35.8 80-80l0-16zM184 112c-39.8 0-72 32.2-72 72 0 13.3-10.7 24-24 24s-24-10.7-24-24c0-66.3 53.7-120 120-120 13.3 0 24 10.7 24 24s-10.7 24-24 24z"></path></svg></span>This Script Was Updated</div><div class="admonitionContent_UjKb"><p>This script was updated after being published, if you're using it please compare the version you have with the version available here.</p><p>This script was last updated on <!-- -->2026/05/31<!-- -->.</p></div></div>
<div class="docusaurus-theme-github-codeblock"><div class="language-powershell codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#9CDCFE;--prism-background-color:#1E1E1E"><div class="codeBlockTitle_OeMC">IntuneStatus.ps1</div><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-powershell codeBlock_bY9V thin-scrollbar" style="color:#9CDCFE;background-color:#1E1E1E"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#9CDCFE"><span class="token plain">loading</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><br></div></code></pre></div></div><div style="font-size:.9em;font-weight:600;color:#0E75DD;text-align:right;padding-bottom:13px;text-decoration:underline"><a href="https://github.com/homotechsual/Blog-Scripts/blob/main/Monitoring/IntuneStatus.ps1" class="githubLink" style="margin:0 10px" target="_blank">View on GitHub</a></div></div>
<div class="theme-admonition theme-admonition-note admonition_Gfwi alert alert--secondary"><div class="admonitionHeading_f1Ed"><span class="admonitionIcon_kpSf"><svg data-prefix="far" data-icon="note-sticky" class="svg-inline--fa fa-note-sticky" role="img" viewBox="0 0 448 512" aria-hidden="true"><path fill="currentColor" d="M240 432L64 432c-8.8 0-16-7.2-16-16L48 96c0-8.8 7.2-16 16-16l320 0c8.8 0 16 7.2 16 16l0 176-88 0c-39.8 0-72 32.2-72 72l0 88zM380.1 320L288 412.1 288 344c0-13.3 10.7-24 24-24l68.1 0zM0 416c0 35.3 28.7 64 64 64l197.5 0c17 0 33.3-6.7 45.3-18.7L429.3 338.7c12-12 18.7-28.3 18.7-45.3L448 96c0-35.3-28.7-64-64-64L64 32C28.7 32 0 60.7 0 96L0 416z"></path></svg></span>note</div><div class="admonitionContent_UjKb"><p>Run this script as <code>SYSTEM</code> in NinjaOne. It validates LocalMachine certificate/registry state and the <code>IntuneManagementExtension</code> service.</p></div></div>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="what-the-script-validates">What The Script Validates<a href="https://homotechsual.dev/2026/05/29/Intune-Status-Health-Check-NinjaOne#what-the-script-validates" class="hash-link" aria-label="Direct link to What The Script Validates" title="Direct link to What The Script Validates" translate="no">​</a></h2>
<p>The script validates multiple indicators before deciding status:</p>
<ol>
<li class="">Azure AD join state (<code>AzureADJoined = YES</code>)</li>
<li class="">Microsoft MDM URL presence (<code>MDMUrl</code>)</li>
<li class="">Tenant ID presence</li>
<li class="">Intune MDM device certificate</li>
<li class="">Intune enrollment GUID from EnterpriseMgmt scheduled task path</li>
<li class="">Primary enrollment GUID selection when multiple registrations exist</li>
<li class="">Required MDM enrollment-related registry keys</li>
<li class="">Intune Management Extension service running</li>
<li class="">Last Intune sync event and result status</li>
</ol>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="script-variables-ninja-script-variables">Script Variables (Ninja Script Variables)<a href="https://homotechsual.dev/2026/05/29/Intune-Status-Health-Check-NinjaOne#script-variables-ninja-script-variables" class="hash-link" aria-label="Direct link to Script Variables (Ninja Script Variables)" title="Direct link to Script Variables (Ninja Script Variables)" translate="no">​</a></h2>
<p>Expose these as NinjaOne script variables if you want field names to be configurable per environment:</p>
<p>The script now reads Ninja script variables from environment variables with the same names as the parameters.</p>
<table><thead><tr><th>Variable</th><th>Type</th><th>Default</th></tr></thead><tbody><tr><td><code>EnrollmentStatusCustomField</code></td><td>String</td><td><code>intuneEnrollmentStatus</code></td></tr><tr><td><code>LogTenantId</code></td><td>Checkbox</td><td><code>true</code></td></tr><tr><td><code>TenantIdCustomField</code></td><td>String</td><td><code>intuneTenantId</code></td></tr><tr><td><code>LogLastSyncAttempt</code></td><td>Checkbox</td><td><code>true</code></td></tr><tr><td><code>LastSyncAttemptCustomField</code></td><td>String</td><td><code>intuneLastSyncAttempt</code></td></tr><tr><td><code>LogLastSyncStatus</code></td><td>Checkbox</td><td><code>true</code></td></tr><tr><td><code>SyncStatusCustomField</code></td><td>String</td><td><code>intuneLastSyncStatus</code></td></tr><tr><td><code>SyncResultLogNames</code></td><td>Text (CSV)</td><td><code>Microsoft-Windows-DeviceManagement-Enterprise-Diagnostics-Provider/Sync,Microsoft-Windows-DeviceManagement-Enterprise-Diagnostics-Provider/Admin</code></td></tr><tr><td><code>SyncResultEventId</code></td><td>Integer</td><td><code>209</code></td></tr></tbody></table>
<p>Example <code>SyncResultLogNames</code> values:</p>
<ul>
<li class=""><code>Microsoft-Windows-DeviceManagement-Enterprise-Diagnostics-Provider/Sync</code></li>
<li class=""><code>Microsoft-Windows-DeviceManagement-Enterprise-Diagnostics-Provider/Sync,Microsoft-Windows-DeviceManagement-Enterprise-Diagnostics-Provider/Admin</code></li>
</ul>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="suggested-ninjaone-monitor-conditions">Suggested NinjaOne Monitor Conditions<a href="https://homotechsual.dev/2026/05/29/Intune-Status-Health-Check-NinjaOne#suggested-ninjaone-monitor-conditions" class="hash-link" aria-label="Direct link to Suggested NinjaOne Monitor Conditions" title="Direct link to Suggested NinjaOne Monitor Conditions" translate="no">​</a></h2>
<p>A practical first monitor set:</p>
<ol>
<li class=""><code>intuneEnrollmentStatus != true</code></li>
<li class=""><code>intuneLastSyncStatus != OK</code></li>
<li class=""><code>intuneLastSyncAttempt</code> older than your policy threshold (for example, 24 hours)</li>
</ol>
<p>Use separate alert severities for enrollment failure vs stale sync to avoid noise.</p>
<h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="suggested-severity-tiers">Suggested Severity Tiers<a href="https://homotechsual.dev/2026/05/29/Intune-Status-Health-Check-NinjaOne#suggested-severity-tiers" class="hash-link" aria-label="Direct link to Suggested Severity Tiers" title="Direct link to Suggested Severity Tiers" translate="no">​</a></h3>
<ul>
<li class="">Critical: <code>intuneEnrollmentStatus != true</code></li>
<li class="">Warning: <code>intuneEnrollmentStatus = true</code> and <code>intuneLastSyncStatus = Error</code></li>
<li class="">Warning/Info: <code>intuneEnrollmentStatus = true</code> and <code>intuneLastSyncStatus = NoData</code> and <code>intuneLastSyncAttempt</code> is older than threshold</li>
</ul>
<div class="theme-admonition theme-admonition-tip admonition_Gfwi alert alert--success"><div class="admonitionHeading_f1Ed"><span class="admonitionIcon_kpSf"><svg data-prefix="fas" data-icon="lightbulb" class="svg-inline--fa fa-lightbulb" role="img" viewBox="0 0 384 512" aria-hidden="true"><path fill="currentColor" d="M292.9 384c7.3-22.3 21.9-42.5 38.4-59.9 32.7-34.4 52.7-80.9 52.7-132.1 0-106-86-192-192-192S0 86 0 192c0 51.2 20 97.7 52.7 132.1 16.5 17.4 31.2 37.6 38.4 59.9l201.7 0zM288 432l-192 0 0 16c0 44.2 35.8 80 80 80l32 0c44.2 0 80-35.8 80-80l0-16zM184 112c-39.8 0-72 32.2-72 72 0 13.3-10.7 24-24 24s-24-10.7-24-24c0-66.3 53.7-120 120-120 13.3 0 24 10.7 24 24s-10.7 24-24 24z"></path></svg></span>tip</div><div class="admonitionContent_UjKb"><p><code>intuneEnrollmentStatus = true</code> means enrollment checks passed enough to classify the device as enrolled. Use <code>intuneLastSyncStatus</code> and <code>intuneLastSyncAttempt</code> to detect degraded or stale sync health.</p></div></div>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="starter-variable-profile">Starter Variable Profile<a href="https://homotechsual.dev/2026/05/29/Intune-Status-Health-Check-NinjaOne#starter-variable-profile" class="hash-link" aria-label="Direct link to Starter Variable Profile" title="Direct link to Starter Variable Profile" translate="no">​</a></h2>
<p>If you want a known-good baseline, start with:</p>
<ul>
<li class=""><code>LogTenantId = true</code></li>
<li class=""><code>LogLastSyncAttempt = true</code></li>
<li class=""><code>LogLastSyncStatus = true</code></li>
<li class=""><code>SyncResultLogNames = Microsoft-Windows-DeviceManagement-Enterprise-Diagnostics-Provider/Sync,Microsoft-Windows-DeviceManagement-Enterprise-Diagnostics-Provider/Admin</code></li>
<li class=""><code>SyncResultEventId = 209</code></li>
</ul>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="example-results">Example Results<a href="https://homotechsual.dev/2026/05/29/Intune-Status-Health-Check-NinjaOne#example-results" class="hash-link" aria-label="Direct link to Example Results" title="Direct link to Example Results" translate="no">​</a></h2>
<p>The script reports status cleanly to NinjaOne fields, including enrollment state, tenant ID, sync status, and last sync timestamp.</p>
<p><img decoding="async" loading="lazy" alt="NinjaOne script output and custom field results for Intune status" src="https://homotechsual.dev/assets/images/NinjaOneIntuneStatusScriptResults-be724bbfe55c31f43fc6eef5131b35ff.png" width="1342" height="275" class="img_ev3q"></p>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="deployment-pattern">Deployment Pattern<a href="https://homotechsual.dev/2026/05/29/Intune-Status-Health-Check-NinjaOne#deployment-pattern" class="hash-link" aria-label="Direct link to Deployment Pattern" title="Direct link to Deployment Pattern" translate="no">​</a></h2>
<p>A simple rollout approach:</p>
<ol>
<li class="">Run script daily on all Intune-managed Windows endpoints.</li>
<li class="">Confirm field population on a pilot device group.</li>
<li class="">Enable monitors after two to three successful daily runs.</li>
<li class="">Add dashboards grouped by tenant/site and exception type.</li>
</ol>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="troubleshooting-notes">Troubleshooting Notes<a href="https://homotechsual.dev/2026/05/29/Intune-Status-Health-Check-NinjaOne#troubleshooting-notes" class="hash-link" aria-label="Direct link to Troubleshooting Notes" title="Direct link to Troubleshooting Notes" translate="no">​</a></h2>
<p>When failures occur, the script output usually points directly to the failing check:</p>
<ul>
<li class=""><code>Device is not Azure AD Joined</code></li>
<li class=""><code>Device does not have a Microsoft MDM URL</code></li>
<li class="">missing enrollment GUID or EnterpriseMgmt task</li>
<li class="">missing enrollment registry branch for detected GUID</li>
<li class="">IntuneManagementExtension service missing/stopped</li>
</ul>
<p><code>NoData</code> can be normal initially on newly enrolled devices until a matching sync result event exists in the selected channel.</p>
<p><code>intuneLastSyncAttempt</code> is written as an unsigned Unix timestamp (seconds since epoch), which matches NinjaOne Date/Time field validation.</p>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="symptom-quick-map">Symptom Quick Map<a href="https://homotechsual.dev/2026/05/29/Intune-Status-Health-Check-NinjaOne#symptom-quick-map" class="hash-link" aria-label="Direct link to Symptom Quick Map" title="Direct link to Symptom Quick Map" translate="no">​</a></h2>
<table><thead><tr><th>Symptom</th><th>Likely Cause / Next Check</th></tr></thead><tbody><tr><td><code>intuneEnrollmentStatus = false</code></td><td>Device likely not fully enrolled; validate <code>dsregcmd /status</code>, MDM URL, and enrollment task path.</td></tr><tr><td><code>intuneEnrollmentStatus = true</code> + <code>intuneLastSyncStatus = Error</code></td><td>Enrollment exists but sync event indicates a failing operation; inspect latest 209 event message in selected log.</td></tr><tr><td><code>intuneEnrollmentStatus = true</code> + <code>intuneLastSyncStatus = NoData</code></td><td>No matching event yet or wrong log/event ID; verify <code>SyncResultLogNames</code> and <code>SyncResultEventId</code>.</td></tr><tr><td>Last sync date not updating</td><td>Confirm <code>LogLastSyncAttempt = true</code> and Date/Time custom field type for <code>intuneLastSyncAttempt</code>.</td></tr></tbody></table>]]></content:encoded>
            <category>NinjaOne</category>
            <category>PowerShell</category>
            <category>Monitoring</category>
            <category>Intune</category>
            <category>Microsoft 365</category>
            <category>Custom Fields</category>
        </item>
        <item>
            <title><![CDATA[Uptime Reboot Policy with NinjaOne and PowerShell]]></title>
            <link>https://homotechsual.dev/2026/05/22/Uptime-Reboot-Policy-NinjaOne</link>
            <guid>https://homotechsual.dev/2026/05/22/Uptime-Reboot-Policy-NinjaOne</guid>
            <pubDate>Fri, 22 May 2026 00:00:00 GMT</pubDate>
            <description><![CDATA[Long-running uptime can be useful, but it also increases risk: pending updates remain pending, patch windows get missed, and users eventually get hit with inconvenient restarts.]]></description>
            <content:encoded><![CDATA[<p>Long-running uptime can be useful, but it also increases risk: pending updates remain pending, patch windows get missed, and users eventually get hit with inconvenient restarts.</p>
<p>This script gives you a practical middle ground:</p>
<ul>
<li class="">Detect when uptime exceeds a threshold</li>
<li class="">Notify the logged-in user with a Windows toast</li>
<li class="">Optionally let the user schedule an earlier reboot</li>
<li class="">Enforce a reboot deadline with a Scheduled Task</li>
<li class="">Write policy state and user action back to NinjaOne custom fields</li>
</ul>
<!-- -->
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="creating-fields">Creating Fields<a href="https://homotechsual.dev/2026/05/22/Uptime-Reboot-Policy-NinjaOne#creating-fields" class="hash-link" aria-label="Direct link to Creating Fields" title="Direct link to Creating Fields" translate="no">​</a></h2>
<div class="theme-admonition theme-admonition-ninja admonition_Gfwi alert alert--ninja"><div class="admonitionHeading_f1Ed"><span class="admonitionIcon_kpSf"><svg data-prefix="fas" data-icon="user-ninja" class="svg-inline--fa fa-user-ninja" role="img" viewBox="0 0 448 512" aria-hidden="true"><path fill="currentColor" d="M352 128c0 70.7-57.3 128-128 128-57.2 0-105.6-37.5-122-89.3-1.1 1.3-2.2 2.6-3.5 3.8-15.8 15.8-38.8 20.7-53.6 22.1-8.1 .8-14.6-5.7-13.8-13.8 1.4-14.7 6.3-37.8 22.1-53.6 5.8-5.8 12.6-10.1 19.6-13.4-7-3.2-13.8-7.6-19.6-13.4-15.8-15.8-20.7-38.8-22.1-53.6-.8-8.1 5.7-14.6 13.8-13.8 14.7 1.4 37.8 6.3 53.6 22.1 4.8 4.8 8.7 10.4 11.7 16.1 21.3-41.2 64.3-69.4 113.8-69.4 70.7 0 128 57.3 128 128zM144 112c0 8.8 7.2 16 16 16l128 0c8.8 0 16-7.2 16-16s-7.2-16-16-16L160 96c-8.8 0-16 7.2-16 16zm-1.4 211l67 50.2c8.5 6.4 20.3 6.4 28.8 0l67-50.2c6.5-4.9 15.2-6.2 22.6-2.8 61.4 28.2 104.1 90.2 104.1 162.1 0 16.4-13.3 29.7-29.7 29.7L45.7 512c-16.4 0-29.7-13.3-29.7-29.7 0-72 42.7-134 104.1-162.1 7.4-3.4 16.1-2.1 22.6 2.8z"></path></svg></span>Creating custom fields in NinjaOne</div><div class="admonitionContent_UjKb">To create a custom field in NinjaOne go to <b>Administration <!-- -->&gt;<!-- --> Devices</b> and select either <b>Role Custom Fields</b> or <b>Global Custom Fields</b> then select <b>Add</b>.<br><br><ul><li>Role Custom Fields are custom fields that are specific to a device role.</li><li>Global Custom Fields are custom fields that are applicable to all devices and/or to a location and/or organisation</li></ul>Make sure you add the fields to the roles you want to use them in at <b>Administration <!-- -->&gt;<!-- --> Devices <!-- -->&gt;<!-- --> Roles</b> (for role custom fields).<br><br>When you create your custom field you need to make sure that you set the <b>Scripts</b> permission to ensure that you can read or write to the field from your scripts - as appropriate for the script you're using.</div></div>
<p>This script can run without custom fields, but adding them gives you much better visibility for reporting and follow-up.</p>
<table><thead><tr><th>Field Label</th><th>Field Name</th><th>Field Type</th><th>Description</th></tr></thead><tbody><tr><td>Last Uptime Reboot Prompt</td><td><code>lastUptimeRebootPrompt</code></td><td>Date/Time</td><td>When the user was last prompted.</td></tr><tr><td>Last Uptime Prompt Action</td><td><code>lastUptimePromptUserAction</code></td><td>Dropdown</td><td>Last recorded user action (<code>Rebooted</code>, <code>Scheduled Reboot</code>, <code>Ignored</code>).</td></tr><tr><td>Last Uptime Reboot Deadline</td><td><code>lastUptimeRebootDeadline</code></td><td>Date/Time</td><td>Current enforced reboot deadline from the script.</td></tr><tr><td>Uptime Reboot Policy State</td><td><code>uptimeRebootPolicyState</code></td><td>Dropdown</td><td>Current policy state (<code>Below Threshold</code>, <code>Threshold Exceeded</code>, <code>Prompt Shown</code>, <code>Deadline Scheduled</code>, <code>Cleanup Completed</code>).</td></tr></tbody></table>
<p><img decoding="async" loading="lazy" alt="Uptime policy custom field definitions in NinjaOne" src="https://homotechsual.dev/assets/images/NinjaOneUptimePolicyCustomFieldSettings-502de89db4f9398536d1051eec198917.png" width="1303" height="200" class="img_ev3q"></p>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="the-script">The Script<a href="https://homotechsual.dev/2026/05/22/Uptime-Reboot-Policy-NinjaOne#the-script" class="hash-link" aria-label="Direct link to The Script" title="Direct link to The Script" translate="no">​</a></h2>
<div class="theme-admonition theme-admonition-tip admonition_Gfwi alert alert--success"><div class="admonitionHeading_f1Ed"><span class="admonitionIcon_kpSf"><svg data-prefix="fas" data-icon="lightbulb" class="svg-inline--fa fa-lightbulb" role="img" viewBox="0 0 384 512" aria-hidden="true"><path fill="currentColor" d="M292.9 384c7.3-22.3 21.9-42.5 38.4-59.9 32.7-34.4 52.7-80.9 52.7-132.1 0-106-86-192-192-192S0 86 0 192c0 51.2 20 97.7 52.7 132.1 16.5 17.4 31.2 37.6 38.4 59.9l201.7 0zM288 432l-192 0 0 16c0 44.2 35.8 80 80 80l32 0c44.2 0 80-35.8 80-80l0-16zM184 112c-39.8 0-72 32.2-72 72 0 13.3-10.7 24-24 24s-24-10.7-24-24c0-66.3 53.7-120 120-120 13.3 0 24 10.7 24 24s-10.7 24-24 24z"></path></svg></span>This Script Was Updated</div><div class="admonitionContent_UjKb"><p>This script was updated after being published, if you're using it please compare the version you have with the version available here.</p><p>This script was last updated on <!-- -->2026/05/22<!-- -->.</p></div></div>
<div class="docusaurus-theme-github-codeblock"><div class="language-powershell codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#9CDCFE;--prism-background-color:#1E1E1E"><div class="codeBlockTitle_OeMC">UptimeRebootPolicy.ps1</div><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-powershell codeBlock_bY9V thin-scrollbar" style="color:#9CDCFE;background-color:#1E1E1E"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#9CDCFE"><span class="token plain">loading</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><br></div></code></pre></div></div><div style="font-size:.9em;font-weight:600;color:#0E75DD;text-align:right;padding-bottom:13px;text-decoration:underline"><a href="https://github.com/homotechsual/Blog-Scripts/blob/main/NinjaOne%20Scripts/UptimeRebootPolicy.ps1" class="githubLink" style="margin:0 10px" target="_blank">View on GitHub</a></div></div>
<p><img decoding="async" loading="lazy" alt="Script run configuration in NinjaOne" src="https://homotechsual.dev/assets/images/NinjaOneUptimePolicyScriptRun-25a7412e552fd784c1762df4e70a3ed5.png" width="536" height="755" class="img_ev3q"></p>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="script-variables">Script Variables<a href="https://homotechsual.dev/2026/05/22/Uptime-Reboot-Policy-NinjaOne#script-variables" class="hash-link" aria-label="Direct link to Script Variables" title="Direct link to Script Variables" translate="no">​</a></h2>
<p>The script has sensible defaults, but these are the key variables to expose in NinjaOne for full control.</p>
<table><thead><tr><th>Ninja Variable Name</th><th>Type</th><th>Default</th><th>What it does</th></tr></thead><tbody><tr><td><code>thresholdDays</code></td><td>Integer</td><td><code>7</code></td><td>Uptime threshold before action starts.</td></tr><tr><td><code>toastTitle</code></td><td>String</td><td><code>Restart Recommended</code></td><td>Toast title shown to the user.</td></tr><tr><td><code>toastMessagePrefix</code></td><td>String</td><td><code>This device has been online for longer than the recommended uptime window.</code></td><td>Prefix used in the toast body.</td></tr><tr><td><code>rebootDeadlineHours</code></td><td>Integer</td><td><code>24</code></td><td>Maximum hours before forced reboot.</td></tr><tr><td><code>enforceRebootDeadline</code></td><td>Checkbox</td><td><code>true</code></td><td>Enables scheduled task enforcement.</td></tr><tr><td><code>allowInteractiveScheduling</code></td><td>Checkbox</td><td><code>true</code></td><td>Allows end-user to choose an earlier reboot.</td></tr><tr><td><code>useRunAsUserForUserExperience</code></td><td>Checkbox</td><td><code>true</code></td><td>Uses RunAsUser when script runs as SYSTEM.</td></tr><tr><td><code>bypassDoNotDisturb</code></td><td>Checkbox</td><td><code>true</code></td><td>Uses an alarm-style toast scenario to surface notifications.</td></tr><tr><td><code>interactivePromptTimeoutSeconds</code></td><td>Integer</td><td><code>120</code></td><td>Auto-close timeout for the interactive prompt UI.</td></tr><tr><td><code>brandName</code></td><td>String</td><td><code>IT Support</code></td><td>Branding header in the prompt UI.</td></tr><tr><td><code>brandSupportText</code></td><td>String</td><td><code>Need help? Contact your IT Service Desk.</code></td><td>Support message in the prompt UI.</td></tr><tr><td><code>brandSupportLabels</code></td><td>String CSV</td><td><code>Portal,Email,Phone</code></td><td>Labels for support options.</td></tr><tr><td><code>brandSupportLinks</code></td><td>String CSV</td><td><code>,,</code></td><td>Matching links/targets for support options.</td></tr><tr><td><code>brandAccentHex</code></td><td>String</td><td><code>0063B1</code></td><td>Accent color used in UI.</td></tr><tr><td><code>rebootTaskName</code></td><td>String</td><td><code>Uptime-Reboot-Deadline</code></td><td>Scheduled task name used for enforcement.</td></tr><tr><td><code>runMode</code></td><td>Dropdown</td><td><code>Auto</code></td><td><code>Auto</code> for normal behavior, <code>CleanupOnly</code> to remove task and exit.</td></tr><tr><td><code>cleanupWhenBelowThreshold</code></td><td>Checkbox</td><td><code>true</code></td><td>Removes reboot task when uptime is below threshold.</td></tr><tr><td><code>logEffectiveConfiguration</code></td><td>Checkbox</td><td><code>true</code></td><td>Logs resolved settings to output.</td></tr><tr><td><code>dryRun</code></td><td>Checkbox</td><td><code>false</code></td><td>Simulates actions without changing anything.</td></tr></tbody></table>
<p><img decoding="async" loading="lazy" alt="Script variable definitions in NinjaOne" src="https://homotechsual.dev/assets/images/NinjaOneUptimePolicyScriptVariables-cc91c5f1749e6462ef4619847bc8571c.png" width="389" height="526" class="img_ev3q"></p>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="how-it-works">How It Works<a href="https://homotechsual.dev/2026/05/22/Uptime-Reboot-Policy-NinjaOne#how-it-works" class="hash-link" aria-label="Direct link to How It Works" title="Direct link to How It Works" translate="no">​</a></h2>
<ol>
<li class="">Reads last boot time from <code>Win32_OperatingSystem</code> and calculates uptime.</li>
<li class="">If uptime is below threshold, it writes <code>Below Threshold</code> and optionally removes any existing reboot task.</li>
<li class="">If uptime is above threshold, it writes <code>Threshold Exceeded</code>, schedules an enforced reboot deadline, and attempts user interaction.</li>
<li class="">If interactive UX is available, the user can:<!-- -->
<ul>
<li class="">reboot in about 2 minutes</li>
<li class="">schedule an earlier reboot in X hours</li>
<li class="">keep the default deadline</li>
</ul>
</li>
<li class="">Displays a toast showing uptime and reboot deadline details.</li>
<li class="">Writes action/policy fields back to NinjaOne for reporting and monitor logic.</li>
</ol>
<p><img decoding="async" loading="lazy" alt="Interactive reboot scheduling prompt shown to users" src="https://homotechsual.dev/assets/images/NinjaOneUptimePolicySchedulerPrompt-e8bf2e4db892115bb6df63f1c2b72c11.png" width="544" height="396" class="img_ev3q"></p>
<p><img decoding="async" loading="lazy" alt="Toast notification shown when uptime threshold is exceeded" src="https://homotechsual.dev/assets/images/NinjaOneUptimePolicyToast-536092f102ab8e10f9bc3601cb02364f.png" width="397" height="232" class="img_ev3q"></p>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="recommended-deployment-pattern">Recommended Deployment Pattern<a href="https://homotechsual.dev/2026/05/22/Uptime-Reboot-Policy-NinjaOne#recommended-deployment-pattern" class="hash-link" aria-label="Direct link to Recommended Deployment Pattern" title="Direct link to Recommended Deployment Pattern" translate="no">​</a></h2>
<p>A reliable deployment pattern is:</p>
<ul>
<li class="">Schedule this script daily on Windows devices</li>
<li class="">Start with the default threshold/deadline (<code>7</code> days / <code>24</code> hours)</li>
<li class="">Create a monitor or dashboard using <code>uptimeRebootPolicyState</code></li>
<li class="">Tune threshold by device role (for example, stricter on user endpoints)</li>
</ul>
<p>For staged rollout, run with <code>dryRun=true</code> first so you can validate logs and field updates without actually creating or removing tasks.</p>
<p><img decoding="async" loading="lazy" alt="Custom field outputs after script execution" src="https://homotechsual.dev/assets/images/NinjaOneUptimePolicyFieldOutputs-dd14e62cf76a7fb6e2465d69d3b1b8d0.png" width="1360" height="275" class="img_ev3q"></p>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="cleanup-mode">Cleanup Mode<a href="https://homotechsual.dev/2026/05/22/Uptime-Reboot-Policy-NinjaOne#cleanup-mode" class="hash-link" aria-label="Direct link to Cleanup Mode" title="Direct link to Cleanup Mode" translate="no">​</a></h2>
<p>If you need to roll back or clear existing deadline tasks, set:</p>
<ul>
<li class=""><code>runMode = CleanupOnly</code></li>
</ul>
<p>That mode removes the reboot deadline task and exits cleanly.</p>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="notes">Notes<a href="https://homotechsual.dev/2026/05/22/Uptime-Reboot-Policy-NinjaOne#notes" class="hash-link" aria-label="Direct link to Notes" title="Direct link to Notes" translate="no">​</a></h2>
<div class="theme-admonition theme-admonition-note admonition_Gfwi alert alert--secondary"><div class="admonitionHeading_f1Ed"><span class="admonitionIcon_kpSf"><svg data-prefix="far" data-icon="note-sticky" class="svg-inline--fa fa-note-sticky" role="img" viewBox="0 0 448 512" aria-hidden="true"><path fill="currentColor" d="M240 432L64 432c-8.8 0-16-7.2-16-16L48 96c0-8.8 7.2-16 16-16l320 0c8.8 0 16 7.2 16 16l0 176-88 0c-39.8 0-72 32.2-72 72l0 88zM380.1 320L288 412.1 288 344c0-13.3 10.7-24 24-24l68.1 0zM0 416c0 35.3 28.7 64 64 64l197.5 0c17 0 33.3-6.7 45.3-18.7L429.3 338.7c12-12 18.7-28.3 18.7-45.3L448 96c0-35.3-28.7-64-64-64L64 32C28.7 32 0 60.7 0 96L0 416z"></path></svg></span>note</div><div class="admonitionContent_UjKb"><p>The script can attempt to install the <code>RunAsUser</code> module when needed for user-context prompts/toasts. In tightly locked-down environments, test this behavior with <code>dryRun=true</code> first and pre-stage dependencies if required.</p></div></div>
<div class="theme-admonition theme-admonition-tip admonition_Gfwi alert alert--success"><div class="admonitionHeading_f1Ed"><span class="admonitionIcon_kpSf"><svg data-prefix="fas" data-icon="lightbulb" class="svg-inline--fa fa-lightbulb" role="img" viewBox="0 0 384 512" aria-hidden="true"><path fill="currentColor" d="M292.9 384c7.3-22.3 21.9-42.5 38.4-59.9 32.7-34.4 52.7-80.9 52.7-132.1 0-106-86-192-192-192S0 86 0 192c0 51.2 20 97.7 52.7 132.1 16.5 17.4 31.2 37.6 38.4 59.9l201.7 0zM288 432l-192 0 0 16c0 44.2 35.8 80 80 80l32 0c44.2 0 80-35.8 80-80l0-16zM184 112c-39.8 0-72 32.2-72 72 0 13.3-10.7 24-24 24s-24-10.7-24-24c0-66.3 53.7-120 120-120 13.3 0 24 10.7 24 24s-10.7 24-24 24z"></path></svg></span>tip</div><div class="admonitionContent_UjKb"><p>If your support links are configured, the interactive prompt can expose quick contact options (portal/email/phone) directly from the reboot scheduling UI.</p></div></div>]]></content:encoded>
            <category>NinjaOne</category>
            <category>PowerShell</category>
            <category>Monitoring</category>
            <category>Reboot Policy</category>
            <category>Custom Fields</category>
            <category>Automation</category>
        </item>
        <item>
            <title><![CDATA[Monitoring Microsoft Office / 365 Apps with PowerShell]]></title>
            <link>https://homotechsual.dev/2024/06/16/Monitoring-Office-M365-Apps-PowerShell</link>
            <guid>https://homotechsual.dev/2024/06/16/Monitoring-Office-M365-Apps-PowerShell</guid>
            <pubDate>Sun, 16 Jun 2024 00:00:00 GMT</pubDate>
            <description><![CDATA[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.]]></description>
            <content:encoded><![CDATA[<p>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.</p>
<details class="details_lb9f alert alert--info details_b_Ee" data-collapsed="true"><summary>Thanks to:</summary><div><div class="collapsibleContent_i85q"><ul>
<li class="">The entire NinjaOne community on the <a href="https://discord.gg/WNUV76cCzS" target="_blank" rel="noopener noreferrer" class="">NinjaOne Discord</a> for the inspiration and support.</li>
<li class=""><a href="https://github.com/davidszp" target="_blank" rel="noopener noreferrer" class="">David Szpunar</a> for his efforts on various M365 / Office apps scripts.</li>
<li class=""><a href="https://cyberdrain.com/" target="_blank" rel="noopener noreferrer" class="">Kelvin Tegelaar</a> for his prior M365 / Office apps scripts.</li>
</ul></div></div></details>
<div class="theme-admonition theme-admonition-security admonition_Gfwi alert alert--security"><div class="admonitionHeading_f1Ed"><span class="admonitionIcon_kpSf"><svg data-prefix="fas" data-icon="shield-halved" class="svg-inline--fa fa-shield-halved" role="img" viewBox="0 0 512 512" aria-hidden="true"><path fill="currentColor" d="M256 0c4.6 0 9.2 1 13.4 2.9L457.8 82.8c22 9.3 38.4 31 38.3 57.2-.5 99.2-41.3 280.7-213.6 363.2-16.7 8-36.1 8-52.8 0-172.4-82.5-213.1-264-213.6-363.2-.1-26.2 16.3-47.9 38.3-57.2L242.7 2.9C246.9 1 251.4 0 256 0zm0 66.8l0 378.1c138-66.8 175.1-214.8 176-303.4l-176-74.6 0 0z"></path></svg></span>security</div><div class="admonitionContent_UjKb"><p>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.</p></div></div>
<!-- -->
<h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="creating-fields">Creating Fields<a href="https://homotechsual.dev/2024/06/16/Monitoring-Office-M365-Apps-PowerShell#creating-fields" class="hash-link" aria-label="Direct link to Creating Fields" title="Direct link to Creating Fields" translate="no">​</a></h3>
<div class="theme-admonition theme-admonition-ninja admonition_Gfwi alert alert--ninja"><div class="admonitionHeading_f1Ed"><span class="admonitionIcon_kpSf"><svg data-prefix="fas" data-icon="user-ninja" class="svg-inline--fa fa-user-ninja" role="img" viewBox="0 0 448 512" aria-hidden="true"><path fill="currentColor" d="M352 128c0 70.7-57.3 128-128 128-57.2 0-105.6-37.5-122-89.3-1.1 1.3-2.2 2.6-3.5 3.8-15.8 15.8-38.8 20.7-53.6 22.1-8.1 .8-14.6-5.7-13.8-13.8 1.4-14.7 6.3-37.8 22.1-53.6 5.8-5.8 12.6-10.1 19.6-13.4-7-3.2-13.8-7.6-19.6-13.4-15.8-15.8-20.7-38.8-22.1-53.6-.8-8.1 5.7-14.6 13.8-13.8 14.7 1.4 37.8 6.3 53.6 22.1 4.8 4.8 8.7 10.4 11.7 16.1 21.3-41.2 64.3-69.4 113.8-69.4 70.7 0 128 57.3 128 128zM144 112c0 8.8 7.2 16 16 16l128 0c8.8 0 16-7.2 16-16s-7.2-16-16-16L160 96c-8.8 0-16 7.2-16 16zm-1.4 211l67 50.2c8.5 6.4 20.3 6.4 28.8 0l67-50.2c6.5-4.9 15.2-6.2 22.6-2.8 61.4 28.2 104.1 90.2 104.1 162.1 0 16.4-13.3 29.7-29.7 29.7L45.7 512c-16.4 0-29.7-13.3-29.7-29.7 0-72 42.7-134 104.1-162.1 7.4-3.4 16.1-2.1 22.6 2.8z"></path></svg></span>Creating custom fields in NinjaOne</div><div class="admonitionContent_UjKb">To create a custom field in NinjaOne go to <b>Administration <!-- -->&gt;<!-- --> Devices</b> and select either <b>Role Custom Fields</b> or <b>Global Custom Fields</b> then select <b>Add</b>.<br><br><ul><li>Role Custom Fields are custom fields that are specific to a device role.</li><li>Global Custom Fields are custom fields that are applicable to all devices and/or to a location and/or organisation</li></ul>Make sure you add the fields to the roles you want to use them in at <b>Administration <!-- -->&gt;<!-- --> Devices <!-- -->&gt;<!-- --> Roles</b> (for role custom fields).<br><br>When you create your custom field you need to make sure that you set the <b>Scripts</b> permission to ensure that you can read or write to the field from your scripts - as appropriate for the script you're using.</div></div>
<p>We're adding one role custom field for devices with the <em>Windows Desktop or Laptop</em> and/or <em>Windows Server</em> 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.</p>
<table><thead><tr><th>Field Label</th><th>Field Name</th><th>Field Type</th><th>Description</th></tr></thead><tbody><tr><td>M365 Apps Installed Version</td><td><code>officeInstalledVersion</code></td><td><code>Text</code></td><td>The installed version of Microsoft Office / 365 Apps.</td></tr><tr><td>M365 Apps Channel</td><td><code>officeChannel</code></td><td><code>Text</code></td><td>The channel of Microsoft Office / 365 Apps.</td></tr><tr><td>M365 Apps Update Status</td><td><code>officeUpdateStatus</code></td><td><code>Text</code></td><td>The update status of Microsoft Office / 365 Apps.</td></tr><tr><td>M365 Apps Secure</td><td><code>officeSecure</code></td><td><code>Checkbox</code></td><td>Whether the latest security (or other) release is installed.</td></tr><tr><td>M365 Apps Detail</td><td><code>officeDetail</code></td><td><code>WYSIWYG</code></td><td>A card containing more detailed information about Microsoft Office / 365 Apps.</td></tr></tbody></table>
<h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="the-script">The Script<a href="https://homotechsual.dev/2024/06/16/Monitoring-Office-M365-Apps-PowerShell#the-script" class="hash-link" aria-label="Direct link to The Script" title="Direct link to The Script" translate="no">​</a></h3>
<div class="docusaurus-theme-github-codeblock"><div class="language-powershell codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#9CDCFE;--prism-background-color:#1E1E1E"><div class="codeBlockTitle_OeMC">Detect-CVE202430103.ps1</div><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-powershell codeBlock_bY9V thin-scrollbar" style="color:#9CDCFE;background-color:#1E1E1E"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#9CDCFE"><span class="token plain">loading</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><br></div></code></pre></div></div><div style="font-size:.9em;font-weight:600;color:#0E75DD;text-align:right;padding-bottom:13px;text-decoration:underline"><a href="https://github.com/homotechsual/Blog-Scripts/blob/main/Monitoring/OfficeSecurityUpdates.ps1" class="githubLink" style="margin:0 10px" target="_blank">View on GitHub</a></div></div>
<h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="the-results">The Results<a href="https://homotechsual.dev/2024/06/16/Monitoring-Office-M365-Apps-PowerShell#the-results" class="hash-link" aria-label="Direct link to The Results" title="Direct link to The Results" translate="no">​</a></h3>
<p><img decoding="async" loading="lazy" alt="M365 Apps Fields" src="https://homotechsual.dev/assets/images/M365AppsFields-109bc21067ec85641c43b3a2e03fea9a.png" width="1324" height="898" class="img_ev3q"></p>
<p>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.</p>]]></content:encoded>
            <category>CVE</category>
            <category>Security</category>
            <category>Vulnerability</category>
            <category>NinjaOne</category>
            <category>Custom Fields</category>
            <category>PowerShell</category>
            <category>Updates</category>
            <category>Microsoft</category>
            <category>Office</category>
            <category>365</category>
        </item>
        <item>
            <title><![CDATA[Initialise PSResourceGet (PowerShellGetv3) and PackageManagement]]></title>
            <link>https://homotechsual.dev/2024/03/26/Initialise-PSResourceGet</link>
            <guid>https://homotechsual.dev/2024/03/26/Initialise-PSResourceGet</guid>
            <pubDate>Tue, 26 Mar 2024 00:00:00 GMT</pubDate>
            <description><![CDATA[PowerShell 5.1 as shipped with Windows 10 and 11 includes versions 1.0.0.1 of PackageManagement and PowerShellGet this old version cannot install most modern modules, nor can it self update properly.]]></description>
            <content:encoded><![CDATA[<p>PowerShell 5.1 as shipped with Windows 10 and 11 includes versions <code>1.0.0.1</code> of <code>PackageManagement</code> and <code>PowerShellGet</code> this old version cannot install most modern modules, nor can it self update properly.</p>
<p>In most cases fixing this runs into numerous issues with conflicting versions or files in use. This script is an adaptation of <a href="https://github.com/christaylorcodes/Initialize-PSGallery/blob/main/PSGalleryHelper.ps1" target="_blank" rel="noopener noreferrer" class="">a script by Chris Taylor</a> which takes a different approach to downloading the modules, has a bit more error checking and further installs the new <code>PSResourceGet</code> module which is the replacement for <code>PowerShellGet</code>.</p>
<!-- -->
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="the-script">The Script<a href="https://homotechsual.dev/2024/03/26/Initialise-PSResourceGet#the-script" class="hash-link" aria-label="Direct link to The Script" title="Direct link to The Script" translate="no">​</a></h2>
<div class="docusaurus-theme-github-codeblock"><div class="language-powershell codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#9CDCFE;--prism-background-color:#1E1E1E"><div class="codeBlockTitle_OeMC">Initialise-PowerShellGet.ps1</div><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-powershell codeBlock_bY9V thin-scrollbar" style="color:#9CDCFE;background-color:#1E1E1E"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#9CDCFE"><span class="token plain">loading</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><br></div></code></pre></div></div><div style="font-size:.9em;font-weight:600;color:#0E75DD;text-align:right;padding-bottom:13px;text-decoration:underline"><a href="https://github.com/homotechsual/Blog-Scripts/blob/main/Update%20Management/InitialisePSResourceGet.ps1" class="githubLink" style="margin:0 10px" target="_blank">View on GitHub</a></div></div>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="usage">Usage<a href="https://homotechsual.dev/2024/03/26/Initialise-PSResourceGet#usage" class="hash-link" aria-label="Direct link to Usage" title="Direct link to Usage" translate="no">​</a></h2>
<div class="language-powershell codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#9CDCFE;--prism-background-color:#1E1E1E"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-powershell codeBlock_bY9V thin-scrollbar" style="color:#9CDCFE;background-color:#1E1E1E"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#9CDCFE"><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><span class="token plain">\Initialise-PowerShellGet</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><span class="token plain">ps1</span><br></div></code></pre></div></div>
<p>Nice and simple on this one, just run the script and it will do the rest. It does expect a close-to-vanilla install of Windows 10 or 11, so if you've been messing around with the default modules before running this script, it may not work as expected.</p>]]></content:encoded>
            <category>CVE</category>
            <category>Security</category>
            <category>Vulnerability</category>
            <category>NinjaOne</category>
            <category>Custom Fields</category>
            <category>PowerShell</category>
        </item>
        <item>
            <title><![CDATA[CVE Detection / Monitoring with NinjaOne Custom Fields]]></title>
            <link>https://homotechsual.dev/2024/02/13/CVE-Monitoring-NinjaOne</link>
            <guid>https://homotechsual.dev/2024/02/13/CVE-Monitoring-NinjaOne</guid>
            <pubDate>Tue, 13 Feb 2024 00:00:00 GMT</pubDate>
            <description><![CDATA[This post will hold detection scripts for any serious CVE vulnerability that we write detection scripts for in the future. It will be updated and added to as new vulnerability detection scripts are written.]]></description>
            <content:encoded><![CDATA[<p>This post will hold detection scripts for any serious CVE vulnerability that we write detection scripts for in the future. It will be updated and added to as new vulnerability detection scripts are written.</p>
<!-- -->
<details class="details_lb9f alert alert--info details_b_Ee" data-collapsed="true"><summary><h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="cve-2022-41099">CVE-2022-41099<a href="https://homotechsual.dev/2024/02/13/CVE-Monitoring-NinjaOne#cve-2022-41099" class="hash-link" aria-label="Direct link to CVE-2022-41099" title="Direct link to CVE-2022-41099" translate="no">​</a></h2></summary><div><div class="collapsibleContent_i85q"><p>This script has been compiled using information from the following Microsoft sources:</p><ul>
<li class=""><a href="https://msrc.microsoft.com/update-guide/vulnerability/CVE-2022-41099" target="_blank" rel="noopener noreferrer" class="">CVE-2022-41099: Security Update Guide</a></li>
<li class=""><a href="https://learn.microsoft.com/en-us/windows-hardware/manufacture/desktop/add-update-to-winre?view=windows-11" target="_blank" rel="noopener noreferrer" class="">Add an update package to Windows RE</a></li>
</ul><div class="theme-admonition theme-admonition-security admonition_Gfwi alert alert--security"><div class="admonitionHeading_f1Ed"><span class="admonitionIcon_kpSf"><svg data-prefix="fas" data-icon="shield-halved" class="svg-inline--fa fa-shield-halved" role="img" viewBox="0 0 512 512" aria-hidden="true"><path fill="currentColor" d="M256 0c4.6 0 9.2 1 13.4 2.9L457.8 82.8c22 9.3 38.4 31 38.3 57.2-.5 99.2-41.3 280.7-213.6 363.2-16.7 8-36.1 8-52.8 0-172.4-82.5-213.1-264-213.6-363.2-.1-26.2 16.3-47.9 38.3-57.2L242.7 2.9C246.9 1 251.4 0 256 0zm0 66.8l0 378.1c138-66.8 175.1-214.8 176-303.4l-176-74.6 0 0z"></path></svg></span>security</div><div class="admonitionContent_UjKb"><p>This article relates to <a href="https://msrc.microsoft.com/update-guide/vulnerability/CVE-2022-41099" target="_blank" rel="noopener noreferrer" class="">CVE-2022-41099</a> which is a vulnerability in the Windows Recovery Environment (WinRE) which could allow a successful attacker to bypass the BitLocker Device Encryption feature on the system storage device. An attacker with physical access to the target could exploit this vulnerability to gain access to encrypted data.</p></div></div><p>:::bug Fixed a Bug</p><p>Thanks to DTGBilly from the <a href="https://discord.gg/MD558SXp" target="_blank" rel="noopener noreferrer" class="">NinjaOne Users Discord</a> for pointing out that in altogether far too many places I had typo'd the CVE as <code>CVE-4022-41099</code> instead of <code>CVE-2022-41099</code> 🤦‍♂️ this included field names and labels so please check yours are correct as now shown in the post.</p><p>:::</p><p>:::note Parameters!</p><p>Since version 1.2.0 (2023-03-21) this script now requires one of two mandatory parameters.</p><ul>
<li class="">
<p>If you are checking for the presence of the small "Safe OS Dynamic Update (SODU)" which is the minimum required change to mitigate the vulnerability use the <code>-CheckPackage</code> parameter and if required alter the <code>-MountDirectory</code> and <code>-LogDirectory</code> parameters (defaults to <code>C:\RMM\WinRE</code>).</p>
</li>
<li class="">
<p>If you are checking for the presence of the larger "Servicing Stack Update (SSU)" or "Dynamic Cumulative Update" which updates more than is required to mitigate the vulnerability, but may offer other benefits including new WinRE functionality or more reliable reset/restore behaviours use the <code>-CheckImage</code> parameter which checks the image build version.</p>
</li>
</ul><p>If you were passing these in NinjaOne your parameter preset might look like this:</p><p><code>-CheckPackage -MountDirectory C:\RMM\WinRE -LogDirectory C:\RMM\WinRE</code></p><p>or this:</p><p><code>-CheckImage</code></p><p>:::</p><p>:::bug Windows Recovery Environment (WinRE) Not Enabled</p><p>Before version 1.3.0 the script did not check if WinRE was enabled which could lead to confusing error output in the event WinRE was disabled. Now if you get the WinRE not enabled warning you are clear on why the script isn't executing.</p><p>A simple <code>reagentc /enable</code> <em>should</em> enable WinRE or at least provide some useful troubleshooting output.</p><p>:::</p><h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="creating-fields">Creating Fields<a href="https://homotechsual.dev/2024/02/13/CVE-Monitoring-NinjaOne#creating-fields" class="hash-link" aria-label="Direct link to Creating Fields" title="Direct link to Creating Fields" translate="no">​</a></h3><div class="theme-admonition theme-admonition-ninja admonition_Gfwi alert alert--ninja"><div class="admonitionHeading_f1Ed"><span class="admonitionIcon_kpSf"><svg data-prefix="fas" data-icon="user-ninja" class="svg-inline--fa fa-user-ninja" role="img" viewBox="0 0 448 512" aria-hidden="true"><path fill="currentColor" d="M352 128c0 70.7-57.3 128-128 128-57.2 0-105.6-37.5-122-89.3-1.1 1.3-2.2 2.6-3.5 3.8-15.8 15.8-38.8 20.7-53.6 22.1-8.1 .8-14.6-5.7-13.8-13.8 1.4-14.7 6.3-37.8 22.1-53.6 5.8-5.8 12.6-10.1 19.6-13.4-7-3.2-13.8-7.6-19.6-13.4-15.8-15.8-20.7-38.8-22.1-53.6-.8-8.1 5.7-14.6 13.8-13.8 14.7 1.4 37.8 6.3 53.6 22.1 4.8 4.8 8.7 10.4 11.7 16.1 21.3-41.2 64.3-69.4 113.8-69.4 70.7 0 128 57.3 128 128zM144 112c0 8.8 7.2 16 16 16l128 0c8.8 0 16-7.2 16-16s-7.2-16-16-16L160 96c-8.8 0-16 7.2-16 16zm-1.4 211l67 50.2c8.5 6.4 20.3 6.4 28.8 0l67-50.2c6.5-4.9 15.2-6.2 22.6-2.8 61.4 28.2 104.1 90.2 104.1 162.1 0 16.4-13.3 29.7-29.7 29.7L45.7 512c-16.4 0-29.7-13.3-29.7-29.7 0-72 42.7-134 104.1-162.1 7.4-3.4 16.1-2.1 22.6 2.8z"></path></svg></span>Creating custom fields in NinjaOne</div><div class="admonitionContent_UjKb">To create a custom field in NinjaOne go to <b>Administration <!-- -->&gt;<!-- --> Devices</b> and select either <b>Role Custom Fields</b> or <b>Global Custom Fields</b> then select <b>Add</b>.<br><br><ul><li>Role Custom Fields are custom fields that are specific to a device role.</li><li>Global Custom Fields are custom fields that are applicable to all devices and/or to a location and/or organisation</li></ul>Make sure you add the fields to the roles you want to use them in at <b>Administration <!-- -->&gt;<!-- --> Devices <!-- -->&gt;<!-- --> Roles</b> (for role custom fields).<br><br>When you create your custom field you need to make sure that you set the <b>Scripts</b> permission to ensure that you can read or write to the field from your scripts - as appropriate for the script you're using.</div></div><p>We're adding one role custom field for devices with the <em>Windows Desktop or Laptop</em> and <em>Windows Server</em> roles, note that we've customised slightly the autogenerated machine name here, if you use the default adjust the field name in the script appropriately.</p><table><thead><tr><th>Field Label</th><th>Field Name</th><th>Field Type</th><th>Description</th></tr></thead><tbody><tr><td>CVE-2022-41099</td><td>CVE202241099</td><td>Checkbox</td><td>Whether the device has a WinRE image vulnerable to CVE-2022-41099</td></tr></tbody></table><h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="the-script">The Script<a href="https://homotechsual.dev/2024/02/13/CVE-Monitoring-NinjaOne#the-script" class="hash-link" aria-label="Direct link to The Script" title="Direct link to The Script" translate="no">​</a></h3><div class="theme-admonition theme-admonition-tip admonition_Gfwi alert alert--success"><div class="admonitionHeading_f1Ed"><span class="admonitionIcon_kpSf"><svg data-prefix="fas" data-icon="lightbulb" class="svg-inline--fa fa-lightbulb" role="img" viewBox="0 0 384 512" aria-hidden="true"><path fill="currentColor" d="M292.9 384c7.3-22.3 21.9-42.5 38.4-59.9 32.7-34.4 52.7-80.9 52.7-132.1 0-106-86-192-192-192S0 86 0 192c0 51.2 20 97.7 52.7 132.1 16.5 17.4 31.2 37.6 38.4 59.9l201.7 0zM288 432l-192 0 0 16c0 44.2 35.8 80 80 80l32 0c44.2 0 80-35.8 80-80l0-16zM184 112c-39.8 0-72 32.2-72 72 0 13.3-10.7 24-24 24s-24-10.7-24-24c0-66.3 53.7-120 120-120 13.3 0 24 10.7 24 24s-10.7 24-24 24z"></path></svg></span>This Script Was Updated</div><div class="admonitionContent_UjKb"><p>This script was updated after being published, if you're using it please compare the version you have with the version available here.</p><p>This script was last updated on <!-- -->2023/04/13<!-- -->.</p></div></div><div class="docusaurus-theme-github-codeblock"><div class="language-powershell codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#9CDCFE;--prism-background-color:#1E1E1E"><div class="codeBlockTitle_OeMC">Detect-CVE202241099.ps1</div><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-powershell codeBlock_bY9V thin-scrollbar" style="color:#9CDCFE;background-color:#1E1E1E"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#9CDCFE"><span class="token plain">loading</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><br></div></code></pre></div></div><div style="font-size:.9em;font-weight:600;color:#0E75DD;text-align:right;padding-bottom:13px;text-decoration:underline"><a href="https://github.com/homotechsual/Blog-Scripts/blob/main/CVE%20Detection/CVE-2022-41099.ps1" class="githubLink" style="margin:0 10px" target="_blank">View on GitHub</a></div></div><h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="the-results">The Results<a href="https://homotechsual.dev/2024/02/13/CVE-Monitoring-NinjaOne#the-results" class="hash-link" aria-label="Direct link to The Results" title="Direct link to The Results" translate="no">​</a></h3><p><img decoding="async" loading="lazy" alt="CVE-2022-41099 Related Custom Fields" src="https://homotechsual.dev/assets/images/NinjaOneCVE202241099Fields-7277667265f3364d8caaa666948be804.png" width="1332" height="125" class="img_ev3q"></p><p>We run this script daily and have a corresponding monitor setup to check CVE fields with a value of "Yes" and alert us if any are found. You'll find information on remediating this vulnerability in <a class="" href="https://homotechsual.dev/2023/01/17/Download-CVE-2022-41099-Patches">this followup post</a>.</p></div></div></details>
<details class="details_lb9f alert alert--info details_b_Ee" data-collapsed="true"><summary><h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="cve-2023-23397">CVE-2023-23397<a href="https://homotechsual.dev/2024/02/13/CVE-Monitoring-NinjaOne#cve-2023-23397" class="hash-link" aria-label="Direct link to CVE-2023-23397" title="Direct link to CVE-2023-23397" translate="no">​</a></h2></summary><div><div class="collapsibleContent_i85q"><p>This script has been compiled using information from the following Microsoft sources:</p><ul>
<li class=""><a href="https://learn.microsoft.com/en-us/officeupdates/microsoft365-apps-security-updates" target="_blank" rel="noopener noreferrer" class="">Release notes for Microsoft Office security updates</a></li>
<li class=""><a href="https://learn.microsoft.com/en-us/officeupdates/update-history-microsoft365-apps-by-date" target="_blank" rel="noopener noreferrer" class="">Update history for Microsoft 365 Apps (by date)</a></li>
<li class=""><a href="https://learn.microsoft.com/en-us/officeupdates/update-history-beta-channel" target="_blank" rel="noopener noreferrer" class="">Update history for Office Beta Channel</a></li>
</ul><details class="details_lb9f alert alert--info details_b_Ee" data-collapsed="true"><summary>Thanks to:</summary><div><div class="collapsibleContent_i85q"><ul>
<li class="">Concentus on the <a href="https://discord.gg/WNUV76cCzS" target="_blank" rel="noopener noreferrer" class="">NinjaOne Users Discord</a> for helping me run down and test different versions of Office to ensure this script was as accurate as possible.</li>
<li class="">Wisecompany on the <a href="https://discord.gg/AhM6tFZpqb" target="_blank" rel="noopener noreferrer" class="">One Man Band MSP Discord</a> for reminding me to add an exit code and not overuse <code>Write-Warning</code>!</li>
<li class="">Thanks to KennyW on the <a href="https://discord.gg/mspgeek" target="_blank" rel="noopener noreferrer" class="">MSPGeek Discord</a> for helping find an error where certain versions were incorrectly detected as not vulnerable!</li>
<li class="">Thanks to Alkerayn on the <a href="https://discord.gg/WNUV76cCzS" target="_blank" rel="noopener noreferrer" class="">NinjaOne Users Discord</a> for helping find an error where certain channels were incorrectly detected as not vulnerable and identifying that we needed to first check the GPO-configured update channel!</li>
<li class="">Thanks to Tanner - MO on the <a href="https://discord.gg/mspexchange" target="_blank" rel="noopener noreferrer" class="">MSPs R Us Discord</a> for pointing out that version comparisons should all use <code>-lt</code> instead of <code>-ne</code> to ensure future compatibility / accuracy.</li>
<li class="">Thanks to DarrenWhite99 on the <a href="https://discord.gg/mspgeek" target="_blank" rel="noopener noreferrer" class="">MSPGeek Discord</a> for pointing out that the check for the GPO UpdateChannel was completely nonsensical and incompletely written.</li>
<li class="">Thanks to JSanz on the <a href="https://discord.gg/WNUV76cCzS" target="_blank" rel="noopener noreferrer" class="">NinjaOne Users Discord</a> for pointing out the GUID matching issue/bug.</li>
<li class="">Thanks to Jhn - TS on the <a href="https://discord.gg/WNUV76cCzS" target="_blank" rel="noopener noreferrer" class="">NinjaOne Users Discord</a> for discovering the issue with empty registry props causing the script to error.</li>
</ul></div></div></details><p>This has only been tested against M365 Apps and Office 2021 VL versions "en masse" and only 64-bit office - if it doesn't work for you let me know on the <a href="https://discord.gg/WNUV76cCzS" target="_blank" rel="noopener noreferrer" class="">NinjaOne Users Discord</a> and I'll see what I can do to fix it!</p><div class="theme-admonition theme-admonition-security admonition_Gfwi alert alert--security"><div class="admonitionHeading_f1Ed"><span class="admonitionIcon_kpSf"><svg data-prefix="fas" data-icon="shield-halved" class="svg-inline--fa fa-shield-halved" role="img" viewBox="0 0 512 512" aria-hidden="true"><path fill="currentColor" d="M256 0c4.6 0 9.2 1 13.4 2.9L457.8 82.8c22 9.3 38.4 31 38.3 57.2-.5 99.2-41.3 280.7-213.6 363.2-16.7 8-36.1 8-52.8 0-172.4-82.5-213.1-264-213.6-363.2-.1-26.2 16.3-47.9 38.3-57.2L242.7 2.9C246.9 1 251.4 0 256 0zm0 66.8l0 378.1c138-66.8 175.1-214.8 176-303.4l-176-74.6 0 0z"></path></svg></span>security</div><div class="admonitionContent_UjKb"><p>This article relates to <a href="https://msrc.microsoft.com/update-guide/vulnerability/CVE-2023-23397" target="_blank" rel="noopener noreferrer" class="">CVE-2023-23397</a> which is a vulnerability in Microsoft Outlook whereby an attacker could access a user's Net-NTLMv2 hash which could be used as a basis of an NTLM Relay attack against another service to authenticate as the user.</p></div></div><h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="creating-fields-1">Creating Fields<a href="https://homotechsual.dev/2024/02/13/CVE-Monitoring-NinjaOne#creating-fields-1" class="hash-link" aria-label="Direct link to Creating Fields" title="Direct link to Creating Fields" translate="no">​</a></h3><div class="theme-admonition theme-admonition-ninja admonition_Gfwi alert alert--ninja"><div class="admonitionHeading_f1Ed"><span class="admonitionIcon_kpSf"><svg data-prefix="fas" data-icon="user-ninja" class="svg-inline--fa fa-user-ninja" role="img" viewBox="0 0 448 512" aria-hidden="true"><path fill="currentColor" d="M352 128c0 70.7-57.3 128-128 128-57.2 0-105.6-37.5-122-89.3-1.1 1.3-2.2 2.6-3.5 3.8-15.8 15.8-38.8 20.7-53.6 22.1-8.1 .8-14.6-5.7-13.8-13.8 1.4-14.7 6.3-37.8 22.1-53.6 5.8-5.8 12.6-10.1 19.6-13.4-7-3.2-13.8-7.6-19.6-13.4-15.8-15.8-20.7-38.8-22.1-53.6-.8-8.1 5.7-14.6 13.8-13.8 14.7 1.4 37.8 6.3 53.6 22.1 4.8 4.8 8.7 10.4 11.7 16.1 21.3-41.2 64.3-69.4 113.8-69.4 70.7 0 128 57.3 128 128zM144 112c0 8.8 7.2 16 16 16l128 0c8.8 0 16-7.2 16-16s-7.2-16-16-16L160 96c-8.8 0-16 7.2-16 16zm-1.4 211l67 50.2c8.5 6.4 20.3 6.4 28.8 0l67-50.2c6.5-4.9 15.2-6.2 22.6-2.8 61.4 28.2 104.1 90.2 104.1 162.1 0 16.4-13.3 29.7-29.7 29.7L45.7 512c-16.4 0-29.7-13.3-29.7-29.7 0-72 42.7-134 104.1-162.1 7.4-3.4 16.1-2.1 22.6 2.8z"></path></svg></span>Creating custom fields in NinjaOne</div><div class="admonitionContent_UjKb">To create a custom field in NinjaOne go to <b>Administration <!-- -->&gt;<!-- --> Devices</b> and select either <b>Role Custom Fields</b> or <b>Global Custom Fields</b> then select <b>Add</b>.<br><br><ul><li>Role Custom Fields are custom fields that are specific to a device role.</li><li>Global Custom Fields are custom fields that are applicable to all devices and/or to a location and/or organisation</li></ul>Make sure you add the fields to the roles you want to use them in at <b>Administration <!-- -->&gt;<!-- --> Devices <!-- -->&gt;<!-- --> Roles</b> (for role custom fields).<br><br>When you create your custom field you need to make sure that you set the <b>Scripts</b> permission to ensure that you can read or write to the field from your scripts - as appropriate for the script you're using.</div></div><p>We're adding one role custom field for devices with the <em>Windows Desktop or Laptop</em> 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.</p><table><thead><tr><th>Field Label</th><th>Field Name</th><th>Field Type</th><th>Description</th></tr></thead><tbody><tr><td>CVE-2023-23397</td><td>CVE202323397</td><td>Checkbox</td><td>Whether the device has an Office or Microsoft 365 Apps version vulnerable to CVE-2023-23397.</td></tr></tbody></table><h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="the-script-1">The Script<a href="https://homotechsual.dev/2024/02/13/CVE-Monitoring-NinjaOne#the-script-1" class="hash-link" aria-label="Direct link to The Script" title="Direct link to The Script" translate="no">​</a></h3><div class="theme-admonition theme-admonition-tip admonition_Gfwi alert alert--success"><div class="admonitionHeading_f1Ed"><span class="admonitionIcon_kpSf"><svg data-prefix="fas" data-icon="lightbulb" class="svg-inline--fa fa-lightbulb" role="img" viewBox="0 0 384 512" aria-hidden="true"><path fill="currentColor" d="M292.9 384c7.3-22.3 21.9-42.5 38.4-59.9 32.7-34.4 52.7-80.9 52.7-132.1 0-106-86-192-192-192S0 86 0 192c0 51.2 20 97.7 52.7 132.1 16.5 17.4 31.2 37.6 38.4 59.9l201.7 0zM288 432l-192 0 0 16c0 44.2 35.8 80 80 80l32 0c44.2 0 80-35.8 80-80l0-16zM184 112c-39.8 0-72 32.2-72 72 0 13.3-10.7 24-24 24s-24-10.7-24-24c0-66.3 53.7-120 120-120 13.3 0 24 10.7 24 24s-10.7 24-24 24z"></path></svg></span>This Script Was Updated</div><div class="admonitionContent_UjKb"><p>This script was updated after being published, if you're using it please compare the version you have with the version available here.</p><p>This script was last updated on <!-- -->2023/04/13<!-- -->.</p></div></div><div class="docusaurus-theme-github-codeblock"><div class="language-powershell codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#9CDCFE;--prism-background-color:#1E1E1E"><div class="codeBlockTitle_OeMC">Detect-CVE202323397.ps1</div><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-powershell codeBlock_bY9V thin-scrollbar" style="color:#9CDCFE;background-color:#1E1E1E"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#9CDCFE"><span class="token plain">loading</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><br></div></code></pre></div></div><div style="font-size:.9em;font-weight:600;color:#0E75DD;text-align:right;padding-bottom:13px;text-decoration:underline"><a href="https://github.com/homotechsual/Blog-Scripts/blob/main/CVE%20Detection/CVE-2023-23397.ps1" class="githubLink" style="margin:0 10px" target="_blank">View on GitHub</a></div></div><h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="the-results-1">The Results<a href="https://homotechsual.dev/2024/02/13/CVE-Monitoring-NinjaOne#the-results-1" class="hash-link" aria-label="Direct link to The Results" title="Direct link to The Results" translate="no">​</a></h3><p><img decoding="async" loading="lazy" alt="CVE-2023-23397 Related Custom Fields" src="https://homotechsual.dev/assets/images/NinjaOneCVE202323397Fields-6100fffda2c3f4ea7fa9b8e11fcffcf9.png" width="1341" height="164" class="img_ev3q"></p><p>We run this script daily and have a corresponding monitor setup to check CVE fields with a value of "Yes" and alert us if any are found. To remediate this vulnerability update Microsoft Office by running something like this:</p><div class="theme-admonition theme-admonition-tip admonition_Gfwi alert alert--success"><div class="admonitionHeading_f1Ed"><span class="admonitionIcon_kpSf"><svg data-prefix="fas" data-icon="lightbulb" class="svg-inline--fa fa-lightbulb" role="img" viewBox="0 0 384 512" aria-hidden="true"><path fill="currentColor" d="M292.9 384c7.3-22.3 21.9-42.5 38.4-59.9 32.7-34.4 52.7-80.9 52.7-132.1 0-106-86-192-192-192S0 86 0 192c0 51.2 20 97.7 52.7 132.1 16.5 17.4 31.2 37.6 38.4 59.9l201.7 0zM288 432l-192 0 0 16c0 44.2 35.8 80 80 80l32 0c44.2 0 80-35.8 80-80l0-16zM184 112c-39.8 0-72 32.2-72 72 0 13.3-10.7 24-24 24s-24-10.7-24-24c0-66.3 53.7-120 120-120 13.3 0 24 10.7 24 24s-10.7 24-24 24z"></path></svg></span>This Script Was Updated</div><div class="admonitionContent_UjKb"><p>This script was updated after being published, if you're using it please compare the version you have with the version available here.</p><p>This script was last updated on <!-- -->2023/03/16<!-- -->.</p></div></div><div class="docusaurus-theme-github-codeblock"><div class="language-powershell codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#9CDCFE;--prism-background-color:#1E1E1E"><div class="codeBlockTitle_OeMC">Update-C2ROffice.ps1</div><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-powershell codeBlock_bY9V thin-scrollbar" style="color:#9CDCFE;background-color:#1E1E1E"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#9CDCFE"><span class="token plain">loading</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><br></div></code></pre></div></div><div style="font-size:.9em;font-weight:600;color:#0E75DD;text-align:right;padding-bottom:13px;text-decoration:underline"><a href="https://github.com/homotechsual/Blog-Scripts/blob/main/Update%20Management/UpdateC2ROffice.ps1" class="githubLink" style="margin:0 10px" target="_blank">View on GitHub</a></div></div><p>This update script will force restart Office apps - it should restore open files automatically but if you want a softer approach replace the <code>Start-Process</code> line with:</p><div class="language-powershell codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#9CDCFE;--prism-background-color:#1E1E1E"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-powershell codeBlock_bY9V thin-scrollbar" style="color:#9CDCFE;background-color:#1E1E1E"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#9CDCFE"><span class="token function" style="color:rgb(220, 220, 170)">Start-Process</span><span class="token plain"> </span><span class="token operator" style="color:rgb(212, 212, 212)">-</span><span class="token plain">FilePath </span><span class="token variable" style="color:rgb(156, 220, 254)">$C2RPath</span><span class="token plain"> </span><span class="token operator" style="color:rgb(212, 212, 212)">-</span><span class="token plain">ArgumentList </span><span class="token string" style="color:rgb(206, 145, 120)">'/update user forceappshutdown=true updatepromptuser=true'</span><span class="token plain"> </span><span class="token operator" style="color:rgb(212, 212, 212)">-</span><span class="token plain">Wait</span><br></div></code></pre></div></div><p>Prejay on the <a href="https://discord.gg/mspgeek" target="_blank" rel="noopener noreferrer" class="">MSPGeek Discord</a> has helpfully suggested the following to update C2R Office builds without a user logged in or as system:</p><div class="language-PowerShell language-powershell codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#9CDCFE;--prism-background-color:#1E1E1E"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-powershell codeBlock_bY9V thin-scrollbar" style="color:#9CDCFE;background-color:#1E1E1E"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#9CDCFE"><span class="token function" style="color:rgb(220, 220, 170)">Start-Process</span><span class="token plain"> </span><span class="token operator" style="color:rgb(212, 212, 212)">-</span><span class="token plain">FilePath </span><span class="token variable" style="color:rgb(156, 220, 254)">$C2RPath</span><span class="token plain"> </span><span class="token operator" style="color:rgb(212, 212, 212)">-</span><span class="token plain">ArgumentList </span><span class="token string" style="color:rgb(206, 145, 120)">'/frequentupdate SCHEDULEDTASK displaylevel=false'</span><span class="token plain"> </span><span class="token operator" style="color:rgb(212, 212, 212)">-</span><span class="token plain">Wait</span><br></div></code></pre></div></div><p>Mark Hodges (also on the <a href="https://discord.gg/mspgeek" target="_blank" rel="noopener noreferrer" class="">MSPGeek Discord</a>) has also helpfully suggested this <a href="https://www.reddit.com/r/sysadmin/comments/11t49mp/cve202323397_outlook_patching_script/" target="_blank" rel="noopener noreferrer" class="">more comprehensive update script which will update Office 2016 and 2019 as well as C2R Office</a>.</p></div></div></details>
<details class="details_lb9f alert alert--info details_b_Ee" data-collapsed="true"><summary><h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="cve-2023-21554">CVE-2023-21554<a href="https://homotechsual.dev/2024/02/13/CVE-Monitoring-NinjaOne#cve-2023-21554" class="hash-link" aria-label="Direct link to CVE-2023-21554" title="Direct link to CVE-2023-21554" translate="no">​</a></h2></summary><div><div class="collapsibleContent_i85q"><p>This script has been compiled using information from the following Microsoft sources:</p><ul>
<li class=""><a href="https://msrc.microsoft.com/update-guide/en-US/vulnerability/CVE-2023-21554" target="_blank" rel="noopener noreferrer" class="">CVE-2023-21554: Security Update Guide</a></li>
</ul><div class="theme-admonition theme-admonition-security admonition_Gfwi alert alert--security"><div class="admonitionHeading_f1Ed"><span class="admonitionIcon_kpSf"><svg data-prefix="fas" data-icon="shield-halved" class="svg-inline--fa fa-shield-halved" role="img" viewBox="0 0 512 512" aria-hidden="true"><path fill="currentColor" d="M256 0c4.6 0 9.2 1 13.4 2.9L457.8 82.8c22 9.3 38.4 31 38.3 57.2-.5 99.2-41.3 280.7-213.6 363.2-16.7 8-36.1 8-52.8 0-172.4-82.5-213.1-264-213.6-363.2-.1-26.2 16.3-47.9 38.3-57.2L242.7 2.9C246.9 1 251.4 0 256 0zm0 66.8l0 378.1c138-66.8 175.1-214.8 176-303.4l-176-74.6 0 0z"></path></svg></span>security</div><div class="admonitionContent_UjKb"><p>This article relates to <a href="https://msrc.microsoft.com/update-guide/en-US/vulnerability/CVE-2023-21554" target="_blank" rel="noopener noreferrer" class="">CVE-2023-21554</a> which is a vulnerability in the Microsoft Message Queuing system which could allow remote code execution.</p></div></div><h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="creating-fields-2">Creating Fields<a href="https://homotechsual.dev/2024/02/13/CVE-Monitoring-NinjaOne#creating-fields-2" class="hash-link" aria-label="Direct link to Creating Fields" title="Direct link to Creating Fields" translate="no">​</a></h3><div class="theme-admonition theme-admonition-ninja admonition_Gfwi alert alert--ninja"><div class="admonitionHeading_f1Ed"><span class="admonitionIcon_kpSf"><svg data-prefix="fas" data-icon="user-ninja" class="svg-inline--fa fa-user-ninja" role="img" viewBox="0 0 448 512" aria-hidden="true"><path fill="currentColor" d="M352 128c0 70.7-57.3 128-128 128-57.2 0-105.6-37.5-122-89.3-1.1 1.3-2.2 2.6-3.5 3.8-15.8 15.8-38.8 20.7-53.6 22.1-8.1 .8-14.6-5.7-13.8-13.8 1.4-14.7 6.3-37.8 22.1-53.6 5.8-5.8 12.6-10.1 19.6-13.4-7-3.2-13.8-7.6-19.6-13.4-15.8-15.8-20.7-38.8-22.1-53.6-.8-8.1 5.7-14.6 13.8-13.8 14.7 1.4 37.8 6.3 53.6 22.1 4.8 4.8 8.7 10.4 11.7 16.1 21.3-41.2 64.3-69.4 113.8-69.4 70.7 0 128 57.3 128 128zM144 112c0 8.8 7.2 16 16 16l128 0c8.8 0 16-7.2 16-16s-7.2-16-16-16L160 96c-8.8 0-16 7.2-16 16zm-1.4 211l67 50.2c8.5 6.4 20.3 6.4 28.8 0l67-50.2c6.5-4.9 15.2-6.2 22.6-2.8 61.4 28.2 104.1 90.2 104.1 162.1 0 16.4-13.3 29.7-29.7 29.7L45.7 512c-16.4 0-29.7-13.3-29.7-29.7 0-72 42.7-134 104.1-162.1 7.4-3.4 16.1-2.1 22.6 2.8z"></path></svg></span>Creating custom fields in NinjaOne</div><div class="admonitionContent_UjKb">To create a custom field in NinjaOne go to <b>Administration <!-- -->&gt;<!-- --> Devices</b> and select either <b>Role Custom Fields</b> or <b>Global Custom Fields</b> then select <b>Add</b>.<br><br><ul><li>Role Custom Fields are custom fields that are specific to a device role.</li><li>Global Custom Fields are custom fields that are applicable to all devices and/or to a location and/or organisation</li></ul>Make sure you add the fields to the roles you want to use them in at <b>Administration <!-- -->&gt;<!-- --> Devices <!-- -->&gt;<!-- --> Roles</b> (for role custom fields).<br><br>When you create your custom field you need to make sure that you set the <b>Scripts</b> permission to ensure that you can read or write to the field from your scripts - as appropriate for the script you're using.</div></div><p>We're adding one role custom field for devices with the <em>Windows Desktop or Laptop</em> 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.</p><table><thead><tr><th>Field Label</th><th>Field Name</th><th>Field Type</th><th>Description</th></tr></thead><tbody><tr><td>CVE-2023-21554</td><td>CVE202321554</td><td>Checkbox</td><td>Whether the device has the MSMQ features installed and is missing the April 2023 Security Update.</td></tr></tbody></table><h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="the-script-2">The Script<a href="https://homotechsual.dev/2024/02/13/CVE-Monitoring-NinjaOne#the-script-2" class="hash-link" aria-label="Direct link to The Script" title="Direct link to The Script" translate="no">​</a></h3><div class="theme-admonition theme-admonition-tip admonition_Gfwi alert alert--success"><div class="admonitionHeading_f1Ed"><span class="admonitionIcon_kpSf"><svg data-prefix="fas" data-icon="lightbulb" class="svg-inline--fa fa-lightbulb" role="img" viewBox="0 0 384 512" aria-hidden="true"><path fill="currentColor" d="M292.9 384c7.3-22.3 21.9-42.5 38.4-59.9 32.7-34.4 52.7-80.9 52.7-132.1 0-106-86-192-192-192S0 86 0 192c0 51.2 20 97.7 52.7 132.1 16.5 17.4 31.2 37.6 38.4 59.9l201.7 0zM288 432l-192 0 0 16c0 44.2 35.8 80 80 80l32 0c44.2 0 80-35.8 80-80l0-16zM184 112c-39.8 0-72 32.2-72 72 0 13.3-10.7 24-24 24s-24-10.7-24-24c0-66.3 53.7-120 120-120 13.3 0 24 10.7 24 24s-10.7 24-24 24z"></path></svg></span>This Script Was Updated</div><div class="admonitionContent_UjKb"><p>This script was updated after being published, if you're using it please compare the version you have with the version available here.</p><p>This script was last updated on <!-- -->2023/03/16<!-- -->.</p></div></div><div class="docusaurus-theme-github-codeblock"><div class="language-powershell codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#9CDCFE;--prism-background-color:#1E1E1E"><div class="codeBlockTitle_OeMC">Detect-CVE202321554.ps1</div><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-powershell codeBlock_bY9V thin-scrollbar" style="color:#9CDCFE;background-color:#1E1E1E"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#9CDCFE"><span class="token plain">loading</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><br></div></code></pre></div></div><div style="font-size:.9em;font-weight:600;color:#0E75DD;text-align:right;padding-bottom:13px;text-decoration:underline"><a href="https://github.com/homotechsual/Blog-Scripts/blob/main/CVE%20Detection/CVE-2023-21554.ps1" class="githubLink" style="margin:0 10px" target="_blank">View on GitHub</a></div></div><h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="the-results-2">The Results<a href="https://homotechsual.dev/2024/02/13/CVE-Monitoring-NinjaOne#the-results-2" class="hash-link" aria-label="Direct link to The Results" title="Direct link to The Results" translate="no">​</a></h3><p><img decoding="async" loading="lazy" alt="CVE-2023-21554 Related Custom Fields" src="https://homotechsual.dev/assets/images/NinjaOneCVE202321554Fields-24b74c8463a96a39c55028bdcdc72c48.png" width="1513" height="224" class="img_ev3q"></p><p>We run this script daily and have a corresponding monitor setup to check CVE fields with a value of "Yes" and alert us if any are found. To remediate install the April 2023 Security Update.</p></div></div></details>
<details class="details_lb9f alert alert--info details_b_Ee" data-collapsed="true"><summary><h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="cve-2023-35628">CVE-2023-35628<a href="https://homotechsual.dev/2024/02/13/CVE-Monitoring-NinjaOne#cve-2023-35628" class="hash-link" aria-label="Direct link to CVE-2023-35628" title="Direct link to CVE-2023-35628" translate="no">​</a></h2></summary><div><div class="collapsibleContent_i85q"><p>This script has been compiled using information from the following Microsoft sources:</p><ul>
<li class=""><a href="https://msrc.microsoft.com/update-guide/vulnerability/CVE-2023-35628" target="_blank" rel="noopener noreferrer" class="">CVE-2023-35628: Security Update Guide</a></li>
</ul><div class="theme-admonition theme-admonition-security admonition_Gfwi alert alert--security"><div class="admonitionHeading_f1Ed"><span class="admonitionIcon_kpSf"><svg data-prefix="fas" data-icon="shield-halved" class="svg-inline--fa fa-shield-halved" role="img" viewBox="0 0 512 512" aria-hidden="true"><path fill="currentColor" d="M256 0c4.6 0 9.2 1 13.4 2.9L457.8 82.8c22 9.3 38.4 31 38.3 57.2-.5 99.2-41.3 280.7-213.6 363.2-16.7 8-36.1 8-52.8 0-172.4-82.5-213.1-264-213.6-363.2-.1-26.2 16.3-47.9 38.3-57.2L242.7 2.9C246.9 1 251.4 0 256 0zm0 66.8l0 378.1c138-66.8 175.1-214.8 176-303.4l-176-74.6 0 0z"></path></svg></span>security</div><div class="admonitionContent_UjKb"><p>This article relates to <a href="https://msrc.microsoft.com/update-guide/vulnerability/CVE-2023-35628" target="_blank" rel="noopener noreferrer" class="">CVE-2023-35628</a> which is a vulnerability affecting Microsoft Outlook's email rendering system which could allow remote code execution.</p></div></div><h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="creating-fields-3">Creating Fields<a href="https://homotechsual.dev/2024/02/13/CVE-Monitoring-NinjaOne#creating-fields-3" class="hash-link" aria-label="Direct link to Creating Fields" title="Direct link to Creating Fields" translate="no">​</a></h3><div class="theme-admonition theme-admonition-ninja admonition_Gfwi alert alert--ninja"><div class="admonitionHeading_f1Ed"><span class="admonitionIcon_kpSf"><svg data-prefix="fas" data-icon="user-ninja" class="svg-inline--fa fa-user-ninja" role="img" viewBox="0 0 448 512" aria-hidden="true"><path fill="currentColor" d="M352 128c0 70.7-57.3 128-128 128-57.2 0-105.6-37.5-122-89.3-1.1 1.3-2.2 2.6-3.5 3.8-15.8 15.8-38.8 20.7-53.6 22.1-8.1 .8-14.6-5.7-13.8-13.8 1.4-14.7 6.3-37.8 22.1-53.6 5.8-5.8 12.6-10.1 19.6-13.4-7-3.2-13.8-7.6-19.6-13.4-15.8-15.8-20.7-38.8-22.1-53.6-.8-8.1 5.7-14.6 13.8-13.8 14.7 1.4 37.8 6.3 53.6 22.1 4.8 4.8 8.7 10.4 11.7 16.1 21.3-41.2 64.3-69.4 113.8-69.4 70.7 0 128 57.3 128 128zM144 112c0 8.8 7.2 16 16 16l128 0c8.8 0 16-7.2 16-16s-7.2-16-16-16L160 96c-8.8 0-16 7.2-16 16zm-1.4 211l67 50.2c8.5 6.4 20.3 6.4 28.8 0l67-50.2c6.5-4.9 15.2-6.2 22.6-2.8 61.4 28.2 104.1 90.2 104.1 162.1 0 16.4-13.3 29.7-29.7 29.7L45.7 512c-16.4 0-29.7-13.3-29.7-29.7 0-72 42.7-134 104.1-162.1 7.4-3.4 16.1-2.1 22.6 2.8z"></path></svg></span>Creating custom fields in NinjaOne</div><div class="admonitionContent_UjKb">To create a custom field in NinjaOne go to <b>Administration <!-- -->&gt;<!-- --> Devices</b> and select either <b>Role Custom Fields</b> or <b>Global Custom Fields</b> then select <b>Add</b>.<br><br><ul><li>Role Custom Fields are custom fields that are specific to a device role.</li><li>Global Custom Fields are custom fields that are applicable to all devices and/or to a location and/or organisation</li></ul>Make sure you add the fields to the roles you want to use them in at <b>Administration <!-- -->&gt;<!-- --> Devices <!-- -->&gt;<!-- --> Roles</b> (for role custom fields).<br><br>When you create your custom field you need to make sure that you set the <b>Scripts</b> permission to ensure that you can read or write to the field from your scripts - as appropriate for the script you're using.</div></div><p>We're adding one role custom field for devices with the <em>Windows Desktop or Laptop</em> and/or <em>Windows Server</em> 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.</p><p>Thanks to <a href="https://gavsto.com/" target="_blank" rel="noopener noreferrer" class="">Gavsto</a> for stopping me doing down the rabbit hole of checking KB numbers by pointing out that it wouldn't be future proof once the next cumulative update was released!</p><table><thead><tr><th>Field Label</th><th>Field Name</th><th>Field Type</th><th>Description</th></tr></thead><tbody><tr><td>CVE-2023-35628</td><td>CVE202335628</td><td>Checkbox</td><td>Whether the device is updated/patched for CVE-2023-35628.</td></tr></tbody></table><h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="the-script-3">The Script<a href="https://homotechsual.dev/2024/02/13/CVE-Monitoring-NinjaOne#the-script-3" class="hash-link" aria-label="Direct link to The Script" title="Direct link to The Script" translate="no">​</a></h3><div class="docusaurus-theme-github-codeblock"><div class="language-powershell codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#9CDCFE;--prism-background-color:#1E1E1E"><div class="codeBlockTitle_OeMC">Detect-CVE202335628.ps1</div><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-powershell codeBlock_bY9V thin-scrollbar" style="color:#9CDCFE;background-color:#1E1E1E"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#9CDCFE"><span class="token plain">loading</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><br></div></code></pre></div></div><div style="font-size:.9em;font-weight:600;color:#0E75DD;text-align:right;padding-bottom:13px;text-decoration:underline"><a href="https://github.com/homotechsual/Blog-Scripts/blob/main/CVE%20Detection/CVE-2023-35628.ps1" class="githubLink" style="margin:0 10px" target="_blank">View on GitHub</a></div></div><h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="the-results-3">The Results<a href="https://homotechsual.dev/2024/02/13/CVE-Monitoring-NinjaOne#the-results-3" class="hash-link" aria-label="Direct link to The Results" title="Direct link to The Results" translate="no">​</a></h3><p><img decoding="async" loading="lazy" alt="CVE-2023-35628 Related Custom Fields" src="https://homotechsual.dev/assets/images/NinjaOneCVE202335628Fields-91b219da2588c4d1bbde17761dc513c5.png" width="1290" height="280" class="img_ev3q"></p><p>We run this script daily and have a corresponding monitor setup to check CVE fields with a value of "Yes" and alert us if any are found. To remediate install the December 2023 Cumulative Update.</p></div></div></details>
<details class="details_lb9f alert alert--info details_b_Ee" data-collapsed="true"><summary><h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="cve-2024-21413">CVE-2024-21413<a href="https://homotechsual.dev/2024/02/13/CVE-Monitoring-NinjaOne#cve-2024-21413" class="hash-link" aria-label="Direct link to CVE-2024-21413" title="Direct link to CVE-2024-21413" translate="no">​</a></h2></summary><div><div class="collapsibleContent_i85q"><div class="theme-admonition theme-admonition-tip admonition_Gfwi alert alert--success"><div class="admonitionHeading_f1Ed"><span class="admonitionIcon_kpSf"><svg data-prefix="fas" data-icon="lightbulb" class="svg-inline--fa fa-lightbulb" role="img" viewBox="0 0 384 512" aria-hidden="true"><path fill="currentColor" d="M292.9 384c7.3-22.3 21.9-42.5 38.4-59.9 32.7-34.4 52.7-80.9 52.7-132.1 0-106-86-192-192-192S0 86 0 192c0 51.2 20 97.7 52.7 132.1 16.5 17.4 31.2 37.6 38.4 59.9l201.7 0zM288 432l-192 0 0 16c0 44.2 35.8 80 80 80l32 0c44.2 0 80-35.8 80-80l0-16zM184 112c-39.8 0-72 32.2-72 72 0 13.3-10.7 24-24 24s-24-10.7-24-24c0-66.3 53.7-120 120-120 13.3 0 24 10.7 24 24s-10.7 24-24 24z"></path></svg></span>This Script Was Updated</div><div class="admonitionContent_UjKb"><p>This script was updated after being published, if you're using it please compare the version you have with the version available here.</p><p>This script was last updated on <!-- -->2023/02/16<!-- -->.</p></div></div><p>This script has been compiled using information from the following Microsoft sources:</p><ul>
<li class=""><a href="https://msrc.microsoft.com/update-guide/vulnerability/CVE-2024-21413" target="_blank" rel="noopener noreferrer" class="">CVE-2024-21413: Security Update Guide</a></li>
</ul><div class="theme-admonition theme-admonition-security admonition_Gfwi alert alert--security"><div class="admonitionHeading_f1Ed"><span class="admonitionIcon_kpSf"><svg data-prefix="fas" data-icon="shield-halved" class="svg-inline--fa fa-shield-halved" role="img" viewBox="0 0 512 512" aria-hidden="true"><path fill="currentColor" d="M256 0c4.6 0 9.2 1 13.4 2.9L457.8 82.8c22 9.3 38.4 31 38.3 57.2-.5 99.2-41.3 280.7-213.6 363.2-16.7 8-36.1 8-52.8 0-172.4-82.5-213.1-264-213.6-363.2-.1-26.2 16.3-47.9 38.3-57.2L242.7 2.9C246.9 1 251.4 0 256 0zm0 66.8l0 378.1c138-66.8 175.1-214.8 176-303.4l-176-74.6 0 0z"></path></svg></span>security</div><div class="admonitionContent_UjKb"><p>This article relates to <a href="https://msrc.microsoft.com/update-guide/vulnerability/CVE-2024-21413" target="_blank" rel="noopener noreferrer" class="">CVE-2023-35628</a> which is a vulnerability affecting Microsoft Outlook's preview pane system which could allow remote code execution.</p></div></div><p>The updates include changes/corrections to the targetted versions - check your version please!</p><h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="creating-fields-4">Creating Fields<a href="https://homotechsual.dev/2024/02/13/CVE-Monitoring-NinjaOne#creating-fields-4" class="hash-link" aria-label="Direct link to Creating Fields" title="Direct link to Creating Fields" translate="no">​</a></h3><div class="theme-admonition theme-admonition-ninja admonition_Gfwi alert alert--ninja"><div class="admonitionHeading_f1Ed"><span class="admonitionIcon_kpSf"><svg data-prefix="fas" data-icon="user-ninja" class="svg-inline--fa fa-user-ninja" role="img" viewBox="0 0 448 512" aria-hidden="true"><path fill="currentColor" d="M352 128c0 70.7-57.3 128-128 128-57.2 0-105.6-37.5-122-89.3-1.1 1.3-2.2 2.6-3.5 3.8-15.8 15.8-38.8 20.7-53.6 22.1-8.1 .8-14.6-5.7-13.8-13.8 1.4-14.7 6.3-37.8 22.1-53.6 5.8-5.8 12.6-10.1 19.6-13.4-7-3.2-13.8-7.6-19.6-13.4-15.8-15.8-20.7-38.8-22.1-53.6-.8-8.1 5.7-14.6 13.8-13.8 14.7 1.4 37.8 6.3 53.6 22.1 4.8 4.8 8.7 10.4 11.7 16.1 21.3-41.2 64.3-69.4 113.8-69.4 70.7 0 128 57.3 128 128zM144 112c0 8.8 7.2 16 16 16l128 0c8.8 0 16-7.2 16-16s-7.2-16-16-16L160 96c-8.8 0-16 7.2-16 16zm-1.4 211l67 50.2c8.5 6.4 20.3 6.4 28.8 0l67-50.2c6.5-4.9 15.2-6.2 22.6-2.8 61.4 28.2 104.1 90.2 104.1 162.1 0 16.4-13.3 29.7-29.7 29.7L45.7 512c-16.4 0-29.7-13.3-29.7-29.7 0-72 42.7-134 104.1-162.1 7.4-3.4 16.1-2.1 22.6 2.8z"></path></svg></span>Creating custom fields in NinjaOne</div><div class="admonitionContent_UjKb">To create a custom field in NinjaOne go to <b>Administration <!-- -->&gt;<!-- --> Devices</b> and select either <b>Role Custom Fields</b> or <b>Global Custom Fields</b> then select <b>Add</b>.<br><br><ul><li>Role Custom Fields are custom fields that are specific to a device role.</li><li>Global Custom Fields are custom fields that are applicable to all devices and/or to a location and/or organisation</li></ul>Make sure you add the fields to the roles you want to use them in at <b>Administration <!-- -->&gt;<!-- --> Devices <!-- -->&gt;<!-- --> Roles</b> (for role custom fields).<br><br>When you create your custom field you need to make sure that you set the <b>Scripts</b> permission to ensure that you can read or write to the field from your scripts - as appropriate for the script you're using.</div></div><p>We're adding one role custom field for devices with the <em>Windows Desktop or Laptop</em> and/or <em>Windows Server</em> 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.</p><table><thead><tr><th>Field Label</th><th>Field Name</th><th>Field Type</th><th>Description</th></tr></thead><tbody><tr><td>CVE-2024-21413</td><td>CVE202421413</td><td>Checkbox</td><td>Whether the device is updated/patched for CVE-2024-21413.</td></tr></tbody></table><h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="the-script-4">The Script<a href="https://homotechsual.dev/2024/02/13/CVE-Monitoring-NinjaOne#the-script-4" class="hash-link" aria-label="Direct link to The Script" title="Direct link to The Script" translate="no">​</a></h3><div class="docusaurus-theme-github-codeblock"><div class="language-powershell codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#9CDCFE;--prism-background-color:#1E1E1E"><div class="codeBlockTitle_OeMC">Detect-CVE202421413.ps1</div><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-powershell codeBlock_bY9V thin-scrollbar" style="color:#9CDCFE;background-color:#1E1E1E"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#9CDCFE"><span class="token plain">loading</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><br></div></code></pre></div></div><div style="font-size:.9em;font-weight:600;color:#0E75DD;text-align:right;padding-bottom:13px;text-decoration:underline"><a href="https://github.com/homotechsual/Blog-Scripts/blob/main/CVE%20Detection/CVE-2024-21413.ps1" class="githubLink" style="margin:0 10px" target="_blank">View on GitHub</a></div></div><h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="the-results-4">The Results<a href="https://homotechsual.dev/2024/02/13/CVE-Monitoring-NinjaOne#the-results-4" class="hash-link" aria-label="Direct link to The Results" title="Direct link to The Results" translate="no">​</a></h3><p><img decoding="async" loading="lazy" alt="CVE-2024-21413 Related Custom Fields" src="https://homotechsual.dev/assets/images/NinjaOneCVE202421413Fields-43cdbab1085ce41556067165537f07c5.png" width="1327" height="286" class="img_ev3q"></p><p>We run this script daily and have a corresponding monitor setup to check CVE fields with a value of "Yes" and alert us if any are found. To remediate install the applicable Office / M365 Apps February 2024 Security Update.</p></div></div></details>
<details class="details_lb9f alert alert--info details_b_Ee" data-collapsed="true"><summary><h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="cve-2024-30103">CVE-2024-30103<a href="https://homotechsual.dev/2024/02/13/CVE-Monitoring-NinjaOne#cve-2024-30103" class="hash-link" aria-label="Direct link to CVE-2024-30103" title="Direct link to CVE-2024-30103" translate="no">​</a></h2></summary><div><div class="collapsibleContent_i85q"><p>This script has been compiled using information from the following Microsoft sources:</p><ul>
<li class=""><a href="https://msrc.microsoft.com/update-guide/vulnerability/CVE-2024-30103" target="_blank" rel="noopener noreferrer" class="">CVE-2024-30103: Security Update Guide</a></li>
</ul><p>This script also uses information from the following non-Microsoft sources:</p><ul>
<li class=""><a href="https://blog.morphisec.com/cve-2024-30103-microsoft-outlook-vulnerability" target="_blank" rel="noopener noreferrer" class="">Morphisec: CVE-2024-30103 Microsoft Outlook Vulnerability</a></li>
</ul><details class="details_lb9f alert alert--info details_b_Ee" data-collapsed="true"><summary>Thanks to:</summary><div><div class="collapsibleContent_i85q"><ul>
<li class="">Xzul on the <a href="https://discord.gg/WNUV76cCzS" target="_blank" rel="noopener noreferrer" class="">NinjaOne Users Discord</a> for bringing this one to the forefront of my attention as I'd seen it and then promptly forgotten about it!</li>
</ul></div></div></details><div class="theme-admonition theme-admonition-security admonition_Gfwi alert alert--security"><div class="admonitionHeading_f1Ed"><span class="admonitionIcon_kpSf"><svg data-prefix="fas" data-icon="shield-halved" class="svg-inline--fa fa-shield-halved" role="img" viewBox="0 0 512 512" aria-hidden="true"><path fill="currentColor" d="M256 0c4.6 0 9.2 1 13.4 2.9L457.8 82.8c22 9.3 38.4 31 38.3 57.2-.5 99.2-41.3 280.7-213.6 363.2-16.7 8-36.1 8-52.8 0-172.4-82.5-213.1-264-213.6-363.2-.1-26.2 16.3-47.9 38.3-57.2L242.7 2.9C246.9 1 251.4 0 256 0zm0 66.8l0 378.1c138-66.8 175.1-214.8 176-303.4l-176-74.6 0 0z"></path></svg></span>security</div><div class="admonitionContent_UjKb"><p>This article relates to <a href="https://msrc.microsoft.com/update-guide/vulnerability/CVE-2024-30103" target="_blank" rel="noopener noreferrer" class="">CVE-2024-30103</a> which is a vulnerability affecting Microsoft Outlook's email rendering system which could allow remote code execution.</p></div></div><h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="creating-fields-5">Creating Fields<a href="https://homotechsual.dev/2024/02/13/CVE-Monitoring-NinjaOne#creating-fields-5" class="hash-link" aria-label="Direct link to Creating Fields" title="Direct link to Creating Fields" translate="no">​</a></h3><div class="theme-admonition theme-admonition-ninja admonition_Gfwi alert alert--ninja"><div class="admonitionHeading_f1Ed"><span class="admonitionIcon_kpSf"><svg data-prefix="fas" data-icon="user-ninja" class="svg-inline--fa fa-user-ninja" role="img" viewBox="0 0 448 512" aria-hidden="true"><path fill="currentColor" d="M352 128c0 70.7-57.3 128-128 128-57.2 0-105.6-37.5-122-89.3-1.1 1.3-2.2 2.6-3.5 3.8-15.8 15.8-38.8 20.7-53.6 22.1-8.1 .8-14.6-5.7-13.8-13.8 1.4-14.7 6.3-37.8 22.1-53.6 5.8-5.8 12.6-10.1 19.6-13.4-7-3.2-13.8-7.6-19.6-13.4-15.8-15.8-20.7-38.8-22.1-53.6-.8-8.1 5.7-14.6 13.8-13.8 14.7 1.4 37.8 6.3 53.6 22.1 4.8 4.8 8.7 10.4 11.7 16.1 21.3-41.2 64.3-69.4 113.8-69.4 70.7 0 128 57.3 128 128zM144 112c0 8.8 7.2 16 16 16l128 0c8.8 0 16-7.2 16-16s-7.2-16-16-16L160 96c-8.8 0-16 7.2-16 16zm-1.4 211l67 50.2c8.5 6.4 20.3 6.4 28.8 0l67-50.2c6.5-4.9 15.2-6.2 22.6-2.8 61.4 28.2 104.1 90.2 104.1 162.1 0 16.4-13.3 29.7-29.7 29.7L45.7 512c-16.4 0-29.7-13.3-29.7-29.7 0-72 42.7-134 104.1-162.1 7.4-3.4 16.1-2.1 22.6 2.8z"></path></svg></span>Creating custom fields in NinjaOne</div><div class="admonitionContent_UjKb">To create a custom field in NinjaOne go to <b>Administration <!-- -->&gt;<!-- --> Devices</b> and select either <b>Role Custom Fields</b> or <b>Global Custom Fields</b> then select <b>Add</b>.<br><br><ul><li>Role Custom Fields are custom fields that are specific to a device role.</li><li>Global Custom Fields are custom fields that are applicable to all devices and/or to a location and/or organisation</li></ul>Make sure you add the fields to the roles you want to use them in at <b>Administration <!-- -->&gt;<!-- --> Devices <!-- -->&gt;<!-- --> Roles</b> (for role custom fields).<br><br>When you create your custom field you need to make sure that you set the <b>Scripts</b> permission to ensure that you can read or write to the field from your scripts - as appropriate for the script you're using.</div></div><p>We're adding one role custom field for devices with the <em>Windows Desktop or Laptop</em> and/or <em>Windows Server</em> 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.</p><table><thead><tr><th>Field Label</th><th>Field Name</th><th>Field Type</th><th>Description</th></tr></thead><tbody><tr><td>CVE-2024-30103</td><td>CVE202430103</td><td>Checkbox</td><td>Whether the device is updated/patched for CVE-2024-30103.</td></tr></tbody></table><h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="the-script-5">The Script<a href="https://homotechsual.dev/2024/02/13/CVE-Monitoring-NinjaOne#the-script-5" class="hash-link" aria-label="Direct link to The Script" title="Direct link to The Script" translate="no">​</a></h3><div class="docusaurus-theme-github-codeblock"><div class="language-powershell codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#9CDCFE;--prism-background-color:#1E1E1E"><div class="codeBlockTitle_OeMC">Detect-CVE202430103.ps1</div><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-powershell codeBlock_bY9V thin-scrollbar" style="color:#9CDCFE;background-color:#1E1E1E"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#9CDCFE"><span class="token plain">loading</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><br></div></code></pre></div></div><div style="font-size:.9em;font-weight:600;color:#0E75DD;text-align:right;padding-bottom:13px;text-decoration:underline"><a href="https://github.com/homotechsual/Blog-Scripts/blob/main/CVE%20Detection/CVE-2024-30103.ps1" class="githubLink" style="margin:0 10px" target="_blank">View on GitHub</a></div></div><h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="the-results-5">The Results<a href="https://homotechsual.dev/2024/02/13/CVE-Monitoring-NinjaOne#the-results-5" class="hash-link" aria-label="Direct link to The Results" title="Direct link to The Results" translate="no">​</a></h3><p><img decoding="async" loading="lazy" alt="CVE-2024-30103 Related Custom Fields" src="https://homotechsual.dev/assets/images/NinjaOneCVE202430103Fields-841ee89eb7a8d1b426fd789104210be8.png" width="1508" height="393" class="img_ev3q"></p><p>We run this script daily and have a corresponding monitor setup to check CVE fields with a value of "Yes" and alert us if any are found. To remediate install the applicable Office / M365 Apps June 2024 Security Update.</p></div></div></details>]]></content:encoded>
            <category>CVE</category>
            <category>Security</category>
            <category>Vulnerability</category>
            <category>NinjaOne</category>
            <category>Custom Fields</category>
            <category>PowerShell</category>
        </item>
        <item>
            <title><![CDATA[Deploying New Teams with PowerShell]]></title>
            <link>https://homotechsual.dev/2024/01/10/Deploy-New-Teams</link>
            <guid>https://homotechsual.dev/2024/01/10/Deploy-New-Teams</guid>
            <pubDate>Wed, 10 Jan 2024 00:00:00 GMT</pubDate>
            <description><![CDATA[This post will show you how to deploy the New Teams client using a PowerShell script.]]></description>
            <content:encoded><![CDATA[<p>This post will show you how to deploy the New Teams client using a PowerShell script.</p>
<!-- -->
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="the-script">The Script<a href="https://homotechsual.dev/2024/01/10/Deploy-New-Teams#the-script" class="hash-link" aria-label="Direct link to The Script" title="Direct link to The Script" translate="no">​</a></h2>
<div class="docusaurus-theme-github-codeblock"><div class="language-powershell codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#9CDCFE;--prism-background-color:#1E1E1E"><div class="codeBlockTitle_OeMC">Install-NewTeams.ps1</div><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-powershell codeBlock_bY9V thin-scrollbar" style="color:#9CDCFE;background-color:#1E1E1E"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#9CDCFE"><span class="token plain">loading</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><br></div></code></pre></div></div><div style="font-size:.9em;font-weight:600;color:#0E75DD;text-align:right;padding-bottom:13px;text-decoration:underline"><a href="https://github.com/homotechsual/Blog-Scripts/blob/main/Software%20Deployment/Generic/NewTeams.ps1" class="githubLink" style="margin:0 10px" target="_blank">View on GitHub</a></div></div>
<p>:::note Parameters
When you run this script you need to pass some parameters. Use <code>-Offline</code> to install using the MSIX file (script will download this if you don't provide it) if you're providing the MSIX provide the path with <code>-MSIXPath</code>. Use <code>-Uninstall</code> to remove the provisioned New Teams package. You can specify your own staging folder with <code>-TeamsFolder</code>.
:::</p>]]></content:encoded>
            <category>Software</category>
            <category>Teams</category>
            <category>Deployment</category>
            <category>PowerShell</category>
        </item>
        <item>
            <title><![CDATA[Disabling (and Clearing) Browser Password Managers with PowerShell]]></title>
            <link>https://homotechsual.dev/2023/12/18/Disabling-Browser-Password-Managers-PowerShell</link>
            <guid>https://homotechsual.dev/2023/12/18/Disabling-Browser-Password-Managers-PowerShell</guid>
            <pubDate>Mon, 18 Dec 2023 00:00:00 GMT</pubDate>
            <description><![CDATA[When deploying a password manager, one of the first things you'll want to do is disable the built-in password manager in your browsers. This is a pretty simple task, but it's also one that's easy to forget. It's also a good idea to clear out any passwords that may have been saved before you deployed your password manager.]]></description>
            <content:encoded><![CDATA[<p>When deploying a password manager, one of the first things you'll want to do is disable the built-in password manager in your browsers. This is a pretty simple task, but it's also one that's easy to forget. It's also a good idea to clear out any passwords that may have been saved before you deployed your password manager.</p>
<p>We automate this for the two browsers we support on managed Windows devices (Edge and Firefox) using PowerShell. Here's how we do it.</p>
<!-- -->
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="edge">Edge<a href="https://homotechsual.dev/2023/12/18/Disabling-Browser-Password-Managers-PowerShell#edge" class="hash-link" aria-label="Direct link to Edge" title="Direct link to Edge" translate="no">​</a></h2>
<p>For Edge we're going to be setting the registry key at <code>HKLM:\SOFTWARE\Policies\Microsoft\Edge\PasswordManagerEnabled</code> to <code>0</code>. This will disable the password manager for all users on the device.</p>
<p>Then we're going to clear out any passwords that may have been saved by deleting the contents of the <code>Login Data</code> file in the user's Edge profile. We'll do this by removing the file entirely.</p>
<p>Now in some cases you only want to do the first part (disabling the password manager) and not the second (clearing out any saved passwords). For that reason the script functionality is controlled with two switch parameters: <code>-DisablePasswordManager</code> and <code>-RemoveExistingPasswords</code>. If you run the script without either of these switches, it will do nothing.</p>
<div class="docusaurus-theme-github-codeblock"><div class="language-powershell codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#9CDCFE;--prism-background-color:#1E1E1E"><div class="codeBlockTitle_OeMC">Application%20Configuration/EdgePasswordManagerConfig.ps1</div><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-powershell codeBlock_bY9V thin-scrollbar" style="color:#9CDCFE;background-color:#1E1E1E"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#9CDCFE"><span class="token plain">loading</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><br></div></code></pre></div></div><div style="font-size:.9em;font-weight:600;color:#0E75DD;text-align:right;padding-bottom:13px;text-decoration:underline"><a href="https://github.com/homotechsual/Blog-Scripts/blob/main/Application%20Configuration/EdgePasswordManagerConfig.ps1" class="githubLink" style="margin:0 10px" target="_blank">View on GitHub</a></div></div>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="firefox">Firefox<a href="https://homotechsual.dev/2023/12/18/Disabling-Browser-Password-Managers-PowerShell#firefox" class="hash-link" aria-label="Direct link to Firefox" title="Direct link to Firefox" translate="no">​</a></h2>
<p>For Firefox we're going to be setting the registry key at <code>HKLM:\SOFTWARE\Policies\Mozilla\Firefox\PasswordManagerEnabled</code> to <code>0</code>. This will disable the password manager for all users on the device.</p>
<p>Then we're going to clear out any passwords that may have been saved by deleting the contents of the <code>logins.json</code> file in the user's Firefox profile and any <code>key*.db</code> files. We'll do this by removing the files entirely.</p>
<p>Now in some cases you only want to do the first part (disabling the password manager) and not the second (clearing out any saved passwords). For that reason the script functionality is controlled with two switch parameters: <code>-DisablePasswordManager</code> and <code>-RemoveExistingPasswords</code>. If you run the script without either of these switches, it will do nothing.</p>
<div class="docusaurus-theme-github-codeblock"><div class="language-powershell codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#9CDCFE;--prism-background-color:#1E1E1E"><div class="codeBlockTitle_OeMC">Application%20Configuration/FirefoxPasswordManagerConfig.ps1</div><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-powershell codeBlock_bY9V thin-scrollbar" style="color:#9CDCFE;background-color:#1E1E1E"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#9CDCFE"><span class="token plain">loading</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><br></div></code></pre></div></div><div style="font-size:.9em;font-weight:600;color:#0E75DD;text-align:right;padding-bottom:13px;text-decoration:underline"><a href="https://github.com/homotechsual/Blog-Scripts/blob/main/Application%20Configuration/FirefoxPasswordManagerConfig.ps1" class="githubLink" style="margin:0 10px" target="_blank">View on GitHub</a></div></div>
<p>As we don't use Chrome, Opera or Safari, we don't have scripts for those browsers. However for other chromium-based browsers a similar approach to Edge should work. It is possible to do this with Safari on MacOS as well but we haven't yet scripted it.</p>]]></content:encoded>
            <category>Configuration</category>
            <category>Password Managers</category>
            <category>Browsers</category>
            <category>PowerShell</category>
        </item>
        <item>
            <title><![CDATA[Monitoring Time Drift with PowerShell]]></title>
            <link>https://homotechsual.dev/2023/03/17/Monitoring-Time-Drift-PowerShell</link>
            <guid>https://homotechsual.dev/2023/03/17/Monitoring-Time-Drift-PowerShell</guid>
            <pubDate>Fri, 17 Mar 2023 00:00:00 GMT</pubDate>
            <description><![CDATA[Sometimes I get a script idea put in my head that's so irritatingly pervasive that the only fix is to write the damned script. David Szpunar from the NinjaOne Users Discord made a somewhat passing comment about time drift causing issues with a remote support tool and that let to me thinking... You could probably monitor for that with a PowerShell one-liner right?]]></description>
            <content:encoded><![CDATA[<p>Sometimes I get a script idea put in my head that's so irritatingly pervasive that the only fix is to write the damned script. David Szpunar from the <a href="https://discord.gg/WNUV76cCzS" target="_blank" rel="noopener noreferrer" class="">NinjaOne Users Discord</a> made a somewhat passing comment about time drift causing issues with a remote support tool and that let to me thinking... You could probably monitor for that with a PowerShell one-liner right?</p>
<p>Wrong! Turns out that it's more than one line!</p>
<!-- -->
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="the-script">The Script<a href="https://homotechsual.dev/2023/03/17/Monitoring-Time-Drift-PowerShell#the-script" class="hash-link" aria-label="Direct link to The Script" title="Direct link to The Script" translate="no">​</a></h2>
<div class="theme-admonition theme-admonition-caution admonition_Gfwi alert alert--warning"><div class="admonitionHeading_f1Ed"><span class="admonitionIcon_kpSf"><svg data-prefix="fas" data-icon="triangle-exclamation" class="svg-inline--fa fa-triangle-exclamation" role="img" viewBox="0 0 512 512" aria-hidden="true"><path fill="currentColor" d="M256 0c14.7 0 28.2 8.1 35.2 21l216 400c6.7 12.4 6.4 27.4-.8 39.5S486.1 480 472 480L40 480c-14.1 0-27.2-7.4-34.4-19.5s-7.5-27.1-.8-39.5l216-400c7-12.9 20.5-21 35.2-21zm0 352a32 32 0 1 0 0 64 32 32 0 1 0 0-64zm0-192c-18.2 0-32.7 15.5-31.4 33.7l7.4 104c.9 12.5 11.4 22.3 23.9 22.3 12.6 0 23-9.7 23.9-22.3l7.4-104c1.3-18.2-13.1-33.7-31.4-33.7z"></path></svg></span>This Script Requires Input</div><div class="admonitionContent_UjKb">This script requires user input, whether in the form of variables, parameters or edits to the script itself before you can run it. Areas where you need to provide input will be indicated with:<div class="language-powershell codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#9CDCFE;--prism-background-color:#1E1E1E"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-powershell codeBlock_bY9V thin-scrollbar" style="color:#9CDCFE;background-color:#1E1E1E"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#9CDCFE"><span class="token comment" style="color:rgb(106, 153, 85)">### Inline Comments</span><br></div></code></pre></div></div>and / or<div class="language-powershell codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#9CDCFE;--prism-background-color:#1E1E1E"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-powershell codeBlock_bY9V thin-scrollbar" style="color:#9CDCFE;background-color:#1E1E1E"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#9CDCFE"><span class="token string" style="color:rgb(206, 145, 120)">'&lt;MARKED STRINGS&gt;'</span><br></div></code></pre></div></div>Parameters will be indicated before the script block.</div></div>
<div class="theme-admonition theme-admonition-tip admonition_Gfwi alert alert--success"><div class="admonitionHeading_f1Ed"><span class="admonitionIcon_kpSf"><svg data-prefix="fas" data-icon="lightbulb" class="svg-inline--fa fa-lightbulb" role="img" viewBox="0 0 384 512" aria-hidden="true"><path fill="currentColor" d="M292.9 384c7.3-22.3 21.9-42.5 38.4-59.9 32.7-34.4 52.7-80.9 52.7-132.1 0-106-86-192-192-192S0 86 0 192c0 51.2 20 97.7 52.7 132.1 16.5 17.4 31.2 37.6 38.4 59.9l201.7 0zM288 432l-192 0 0 16c0 44.2 35.8 80 80 80l32 0c44.2 0 80-35.8 80-80l0-16zM184 112c-39.8 0-72 32.2-72 72 0 13.3-10.7 24-24 24s-24-10.7-24-24c0-66.3 53.7-120 120-120 13.3 0 24 10.7 24 24s-10.7 24-24 24z"></path></svg></span>This Script Was Updated</div><div class="admonitionContent_UjKb"><p>This script was updated after being published, if you're using it please compare the version you have with the version available here.</p><p>This script was last updated on <!-- -->2023/03/17<!-- -->.</p></div></div>
<div class="docusaurus-theme-github-codeblock"><div class="language-powershell codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#9CDCFE;--prism-background-color:#1E1E1E"><div class="codeBlockTitle_OeMC">Test-TimeDrift.ps1</div><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-powershell codeBlock_bY9V thin-scrollbar" style="color:#9CDCFE;background-color:#1E1E1E"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#9CDCFE"><span class="token plain">loading</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><br></div></code></pre></div></div><div style="font-size:.9em;font-weight:600;color:#0E75DD;text-align:right;padding-bottom:13px;text-decoration:underline"><a href="https://github.com/homotechsual/Blog-Scripts/blob/main/Monitoring/TimeDrift.ps1" class="githubLink" style="margin:0 10px" target="_blank">View on GitHub</a></div></div>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="using-the-script">Using The Script<a href="https://homotechsual.dev/2023/03/17/Monitoring-Time-Drift-PowerShell#using-the-script" class="hash-link" aria-label="Direct link to Using The Script" title="Direct link to Using The Script" translate="no">​</a></h2>
<p>We tested this as a "Script Result Condition" in NinjaOne set to trigger the monitor if a machine's time drifts by more than 10 seconds from <code>uk.pool.ntp.org</code> (the UK's NTP pool) and it worked like a charm. The script is pretty self-explanatory but here's a quick rundown of what it does:</p>
<ol>
<li class="">It uses a configurable NTP or SNTP server to get the "reference" time. (Parameter <code>-ReferenceServer</code>)</li>
<li class="">It uses the <code>w32tm</code> executable to conduct a number of skew checks against that reference server (Parameter <code>-NumberOfSamples</code>)</li>
<li class="">It averages the samples and compares the result to the threshold (Parameter <code>-AllowedTimeDrift</code>)</li>
<li class="">Optionally you can force a resync if the time drift is greater than the threshold (Parameter <code>-ForceResync</code>)</li>
</ol>
<p>If the average time drift is greater than the threshold, the script returns a non-zero exit code and the monitor triggers. If the <code>w32tm</code> command errors (non existent server, network down etc) the script returns a non-zero exit code and the monitor triggers.</p>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="credits">Credits<a href="https://homotechsual.dev/2023/03/17/Monitoring-Time-Drift-PowerShell#credits" class="hash-link" aria-label="Direct link to Credits" title="Direct link to Credits" translate="no">​</a></h2>
<p>This script borrows ideas and the approach and a little code from the excellent blog of <a href="https://kevinholman.com/2017/08/26/monitoring-for-time-drift-in-your-enterprise/" target="_blank" rel="noopener noreferrer" class="">Kevin Holman</a>.</p>
<p>The formidable <a href="https://christaylor.codes/" target="_blank" rel="noopener noreferrer" class="">Chris Taylor</a> helped with a cool suggestion to suppress empty lines in the output and his site is well worth a visit.</p>]]></content:encoded>
            <category>Monitoring</category>
            <category>PowerShell</category>
        </item>
        <item>
            <title><![CDATA[Targeting Windows Versions for Feature Updates]]></title>
            <link>https://homotechsual.dev/2023/02/16/Targeting-Windows-Versions-for-Feature-Updates</link>
            <guid>https://homotechsual.dev/2023/02/16/Targeting-Windows-Versions-for-Feature-Updates</guid>
            <pubDate>Thu, 16 Feb 2023 00:00:00 GMT</pubDate>
            <description><![CDATA[This post will show you how to use registry keys to test, set and remove target versions for Windows Feature Updates. This allows you to prevent Windows 10 or 11 from updating past your configured limit.]]></description>
            <content:encoded><![CDATA[<p>This post will show you how to use registry keys to test, set and remove target versions for Windows Feature Updates. This allows you to prevent Windows 10 or 11 from updating past your configured limit.</p>
<!-- -->
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="the-script">The Script<a href="https://homotechsual.dev/2023/02/16/Targeting-Windows-Versions-for-Feature-Updates#the-script" class="hash-link" aria-label="Direct link to The Script" title="Direct link to The Script" translate="no">​</a></h2>
<div class="theme-admonition theme-admonition-tip admonition_Gfwi alert alert--success"><div class="admonitionHeading_f1Ed"><span class="admonitionIcon_kpSf"><svg data-prefix="fas" data-icon="lightbulb" class="svg-inline--fa fa-lightbulb" role="img" viewBox="0 0 384 512" aria-hidden="true"><path fill="currentColor" d="M292.9 384c7.3-22.3 21.9-42.5 38.4-59.9 32.7-34.4 52.7-80.9 52.7-132.1 0-106-86-192-192-192S0 86 0 192c0 51.2 20 97.7 52.7 132.1 16.5 17.4 31.2 37.6 38.4 59.9l201.7 0zM288 432l-192 0 0 16c0 44.2 35.8 80 80 80l32 0c44.2 0 80-35.8 80-80l0-16zM184 112c-39.8 0-72 32.2-72 72 0 13.3-10.7 24-24 24s-24-10.7-24-24c0-66.3 53.7-120 120-120 13.3 0 24 10.7 24 24s-10.7 24-24 24z"></path></svg></span>This Script Was Updated</div><div class="admonitionContent_UjKb"><p>This script was updated after being published, if you're using it please compare the version you have with the version available here.</p><p>This script was last updated on <!-- -->2023/04/05<!-- -->.</p></div></div>
<div class="docusaurus-theme-github-codeblock"><div class="language-powershell codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#9CDCFE;--prism-background-color:#1E1E1E"><div class="codeBlockTitle_OeMC">Invoke-WindowsUpdateTargetVersion.ps1</div><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-powershell codeBlock_bY9V thin-scrollbar" style="color:#9CDCFE;background-color:#1E1E1E"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#9CDCFE"><span class="token plain">loading</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><br></div></code></pre></div></div><div style="font-size:.9em;font-weight:600;color:#0E75DD;text-align:right;padding-bottom:13px;text-decoration:underline"><a href="https://github.com/homotechsual/Blog-Scripts/blob/main/Update%20Management/FeatureUpdateTargeting.ps1" class="githubLink" style="margin:0 10px" target="_blank">View on GitHub</a></div></div>
<p>:::note Parameters</p>
<p>When you run this script you might want to pass some parameters - here's what they do:</p>
<ul>
<li class=""><code>-Test</code> - This will test the current target version settings and show you the results.</li>
<li class=""><code>-Unset</code> - This will remove the target version settings.</li>
<li class=""><code>-TargetProductVersion</code> - Specify the target version to aim for, examples would be <code>21H2</code> or <code>22H2</code>.</li>
<li class=""><code>-TargetProduct</code> - Specify the target product to aim for, examples would be <code>Windows 10</code> or <code>Windows 11</code>.</li>
</ul>
<p>:::</p>]]></content:encoded>
            <category>Software</category>
            <category>Windows</category>
            <category>Updates</category>
            <category>Registry</category>
            <category>PowerShell</category>
        </item>
        <item>
            <title><![CDATA[Downloading CVE-2022-41099 Patch and SSU files]]></title>
            <link>https://homotechsual.dev/2023/01/17/Download-CVE-2022-41099-Patches</link>
            <guid>https://homotechsual.dev/2023/01/17/Download-CVE-2022-41099-Patches</guid>
            <pubDate>Tue, 17 Jan 2023 21:25:00 GMT</pubDate>
            <description><![CDATA[<CodeSource]]></description>
            <content:encoded><![CDATA[<span class="hero__wrapper"><section class="post__hero hero shadow--md bordered"><div class="container"><h2 class="hero__title"><strong>Collaboration with Martin Himken</strong></h2><p class="hero__subtitle">This post and the WinRE patching script on Martin's blog at https://manima.de are the result of a collaboration between Martin and I to help mutually improve our various efforts towards patching CVE-2022-41099.</p><div class="hero__button"><a class="button button--primary button--outline button--lg" href="https://manima.de/2023/01/modify-winre-patches-drivers-and-cve-2022-41099/">Read Martin's blog on WinRE patching</a></div></div></section></span>
<div class="theme-admonition theme-admonition-security admonition_Gfwi alert alert--security"><div class="admonitionHeading_f1Ed"><span class="admonitionIcon_kpSf"><svg data-prefix="fas" data-icon="shield-halved" class="svg-inline--fa fa-shield-halved" role="img" viewBox="0 0 512 512" aria-hidden="true"><path fill="currentColor" d="M256 0c4.6 0 9.2 1 13.4 2.9L457.8 82.8c22 9.3 38.4 31 38.3 57.2-.5 99.2-41.3 280.7-213.6 363.2-16.7 8-36.1 8-52.8 0-172.4-82.5-213.1-264-213.6-363.2-.1-26.2 16.3-47.9 38.3-57.2L242.7 2.9C246.9 1 251.4 0 256 0zm0 66.8l0 378.1c138-66.8 175.1-214.8 176-303.4l-176-74.6 0 0z"></path></svg></span>security</div><div class="admonitionContent_UjKb"><p>This article relates to <a href="https://msrc.microsoft.com/update-guide/vulnerability/CVE-2022-41099" target="_blank" rel="noopener noreferrer" class="">CVE-2022-41099</a> which is a vulnerability in the Windows Recovery Environment (WinRE) which could allow a successful attacker to bypass the BitLocker Device Encryption feature on the system storage device. An attacker with physical access to the target could exploit this vulnerability to gain access to encrypted data.</p></div></div>
<!-- -->
<p>If you're running Windows 10 or 11 you might have come across CVE-2022-41099 which is a vulnerability in the Windows Recovery Environment (WinRE) which could allow a successful attacker to bypass BitLocker if they can boot the device to WinRE. This is a pretty serious vulnerability and Microsoft have released a patch for it. However, the patch is not applied automatically and you need to take action to apply it.</p>
<p>Martin Himken has written a script to patch the WinRE drivers and I've written a script to download and stage the patch and servicing stack update files. The link to Martin's blog is at the top of this post and will be repeated at the end.</p>
<p>This script takes a few parameters to control it's behaviour. Parameter documentation follows:</p>
<table><thead><tr><th>Parameter</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td>PatchFolder</td><td>DirectoryInfo</td><td>The folder to download the patch files to. If not specified, <code>C:\RMM\CVEs\2022-41099\</code> will be used.</td></tr><tr><td>All</td><td>Switch</td><td>If specified, the script will download the patch files for all supported versions and available architechtures of Windows 10 and 11. If not specified, the script will only download the patch files for the version of Windows that is running on the device.</td></tr></tbody></table>
<p>:::warning -All
Using the <code>-All</code> parameter will download a lot of files and take a long time to complete. It is recommended that you only use this parameter if you are patching a large number of devices or want to prepare a cache to serve files from.</p>
<p>Downloading all files consumes roughly 4.9GB of disk space.
:::</p>
<h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="the-script">The Script<a href="https://homotechsual.dev/2023/01/17/Download-CVE-2022-41099-Patches#the-script" class="hash-link" aria-label="Direct link to The Script" title="Direct link to The Script" translate="no">​</a></h3>
<div class="theme-admonition theme-admonition-info admonition_Gfwi alert alert--info"><div class="admonitionHeading_f1Ed"><span class="admonitionIcon_kpSf"><svg data-prefix="fas" data-icon="circle-info" class="svg-inline--fa fa-circle-info" role="img" viewBox="0 0 512 512" aria-hidden="true"><path fill="currentColor" d="M256 512a256 256 0 1 0 0-512 256 256 0 1 0 0 512zM224 160a32 32 0 1 1 64 0 32 32 0 1 1 -64 0zm-8 64l48 0c13.3 0 24 10.7 24 24l0 88 8 0c13.3 0 24 10.7 24 24s-10.7 24-24 24l-80 0c-13.3 0-24-10.7-24-24s10.7-24 24-24l24 0 0-64-24 0c-13.3 0-24-10.7-24-24s10.7-24 24-24z"></path></svg></span>info</div><div class="admonitionContent_UjKb"><p>This new version of the script downloads the Safe OS Dynamic Update (SODU) files - these are tiny and designed only to patch the vulnerable components.</p></div></div>
<details class="details_lb9f alert alert--info details_b_Ee" data-collapsed="true"><summary>Safe OS Dynamic Update (SODU) version.</summary><div><div class="collapsibleContent_i85q"><div class="theme-admonition theme-admonition-tip admonition_Gfwi alert alert--success"><div class="admonitionHeading_f1Ed"><span class="admonitionIcon_kpSf"><svg data-prefix="fas" data-icon="lightbulb" class="svg-inline--fa fa-lightbulb" role="img" viewBox="0 0 384 512" aria-hidden="true"><path fill="currentColor" d="M292.9 384c7.3-22.3 21.9-42.5 38.4-59.9 32.7-34.4 52.7-80.9 52.7-132.1 0-106-86-192-192-192S0 86 0 192c0 51.2 20 97.7 52.7 132.1 16.5 17.4 31.2 37.6 38.4 59.9l201.7 0zM288 432l-192 0 0 16c0 44.2 35.8 80 80 80l32 0c44.2 0 80-35.8 80-80l0-16zM184 112c-39.8 0-72 32.2-72 72 0 13.3-10.7 24-24 24s-24-10.7-24-24c0-66.3 53.7-120 120-120 13.3 0 24 10.7 24 24s-10.7 24-24 24z"></path></svg></span>This Script Was Updated</div><div class="admonitionContent_UjKb"><p>This script was updated after being published, if you're using it please compare the version you have with the version available here.</p><p>This script was last updated on <!-- -->2023/03/22<!-- -->.</p></div></div><div class="docusaurus-theme-github-codeblock"><div class="language-powershell codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#9CDCFE;--prism-background-color:#1E1E1E"><div class="codeBlockTitle_OeMC">Get-CVE202241099Patches.ps1</div><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-powershell codeBlock_bY9V thin-scrollbar" style="color:#9CDCFE;background-color:#1E1E1E"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#9CDCFE"><span class="token plain">loading</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><br></div></code></pre></div></div><div style="font-size:.9em;font-weight:600;color:#0E75DD;text-align:right;padding-bottom:13px;text-decoration:underline"><a href="https://github.com/homotechsual/Blog-Scripts/blob/main/Update%20Management/CVE202241099DownloaderSODU.ps1" class="githubLink" style="margin:0 10px" target="_blank">View on GitHub</a></div></div><p>:::note Change Logs</p><h4 class="anchor anchorTargetStickyNavbar_Vzrq" id="version-15">Version: 1.5<a href="https://homotechsual.dev/2023/01/17/Download-CVE-2022-41099-Patches#version-15" class="hash-link" aria-label="Direct link to Version: 1.5" title="Direct link to Version: 1.5" translate="no">​</a></h4><p>Fixes incorrectly switched URLs for 19042 to 19045 for the x86 and x64 downloads. Thanks to Wisecompany for helping find this.</p><h4 class="anchor anchorTargetStickyNavbar_Vzrq" id="version-14">Version: 1.4<a href="https://homotechsual.dev/2023/01/17/Download-CVE-2022-41099-Patches#version-14" class="hash-link" aria-label="Direct link to Version: 1.4" title="Direct link to Version: 1.4" translate="no">​</a></h4><p>Update to use the Safe OS Dynamic Update packages which are considerably smaller.</p><h4 class="anchor anchorTargetStickyNavbar_Vzrq" id="version-13">Version: 1.3<a href="https://homotechsual.dev/2023/01/17/Download-CVE-2022-41099-Patches#version-13" class="hash-link" aria-label="Direct link to Version: 1.3" title="Direct link to Version: 1.3" translate="no">​</a></h4><p>Use <code>$ProgressPreference</code> to speed up execution. Thanks to <a href="https://github.com/CodyRWhite" target="_blank" rel="noopener noreferrer" class="">https://github.com/CodyRWhite</a> for the suggestion.</p><h4 class="anchor anchorTargetStickyNavbar_Vzrq" id="version-12">Version: 1.2<a href="https://homotechsual.dev/2023/01/17/Download-CVE-2022-41099-Patches#version-12" class="hash-link" aria-label="Direct link to Version: 1.2" title="Direct link to Version: 1.2" translate="no">​</a></h4><p>Fix a bug on line 82 where a hashtable of architectures was attempted to be accessed using the Windows build number. Thanks to Sir Loin of House WinAdmins for spotting this. (Yes, it's a Game of Thrones reference. So original.)</p><h4 class="anchor anchorTargetStickyNavbar_Vzrq" id="version-11">Version: 1.1<a href="https://homotechsual.dev/2023/01/17/Download-CVE-2022-41099-Patches#version-11" class="hash-link" aria-label="Direct link to Version: 1.1" title="Direct link to Version: 1.1" translate="no">​</a></h4><p>Adds handling for 19044.</p><h4 class="anchor anchorTargetStickyNavbar_Vzrq" id="version-10">Version: 1.0<a href="https://homotechsual.dev/2023/01/17/Download-CVE-2022-41099-Patches#version-10" class="hash-link" aria-label="Direct link to Version: 1.0" title="Direct link to Version: 1.0" translate="no">​</a></h4><p>Initial release.</p><p>:::</p></div></div></details>
<div class="theme-admonition theme-admonition-info admonition_Gfwi alert alert--info"><div class="admonitionHeading_f1Ed"><span class="admonitionIcon_kpSf"><svg data-prefix="fas" data-icon="circle-info" class="svg-inline--fa fa-circle-info" role="img" viewBox="0 0 512 512" aria-hidden="true"><path fill="currentColor" d="M256 512a256 256 0 1 0 0-512 256 256 0 1 0 0 512zM224 160a32 32 0 1 1 64 0 32 32 0 1 1 -64 0zm-8 64l48 0c13.3 0 24 10.7 24 24l0 88 8 0c13.3 0 24 10.7 24 24s-10.7 24-24 24l-80 0c-13.3 0-24-10.7-24-24s10.7-24 24-24l24 0 0-64-24 0c-13.3 0-24-10.7-24-24s10.7-24 24-24z"></path></svg></span>info</div><div class="admonitionContent_UjKb"><p>This version of the script downloads the SSU and Dynamic Cumulative Update files - these are large and designed to update WinRE completely not just patch the vulnerability.</p></div></div>
<details class="details_lb9f alert alert--info details_b_Ee" data-collapsed="true"><summary>Servicing Stack Update (SSU) and Dynamic Cumulative Update (DCU) version.</summary><div><div class="collapsibleContent_i85q"><p>:::warning Large Files</p><p>This script downloads the SSU and Dynamic Cumulative Update files - these are large and designed to update WinRE completely not just patch the vulnerability. This will require a lot of space both to download them (especially if using <code>-All</code>) and to apply them to WinRE.</p><p>:::</p><div class="theme-admonition theme-admonition-tip admonition_Gfwi alert alert--success"><div class="admonitionHeading_f1Ed"><span class="admonitionIcon_kpSf"><svg data-prefix="fas" data-icon="lightbulb" class="svg-inline--fa fa-lightbulb" role="img" viewBox="0 0 384 512" aria-hidden="true"><path fill="currentColor" d="M292.9 384c7.3-22.3 21.9-42.5 38.4-59.9 32.7-34.4 52.7-80.9 52.7-132.1 0-106-86-192-192-192S0 86 0 192c0 51.2 20 97.7 52.7 132.1 16.5 17.4 31.2 37.6 38.4 59.9l201.7 0zM288 432l-192 0 0 16c0 44.2 35.8 80 80 80l32 0c44.2 0 80-35.8 80-80l0-16zM184 112c-39.8 0-72 32.2-72 72 0 13.3-10.7 24-24 24s-24-10.7-24-24c0-66.3 53.7-120 120-120 13.3 0 24 10.7 24 24s-10.7 24-24 24z"></path></svg></span>This Script Was Updated</div><div class="admonitionContent_UjKb"><p>This script was updated after being published, if you're using it please compare the version you have with the version available here.</p><p>This script was last updated on <!-- -->2023/03/22<!-- -->.</p></div></div><div class="docusaurus-theme-github-codeblock"><div class="language-powershell codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#9CDCFE;--prism-background-color:#1E1E1E"><div class="codeBlockTitle_OeMC">Get-CVE202241099Patches.ps1</div><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-powershell codeBlock_bY9V thin-scrollbar" style="color:#9CDCFE;background-color:#1E1E1E"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#9CDCFE"><span class="token plain">loading</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><br></div></code></pre></div></div><div style="font-size:.9em;font-weight:600;color:#0E75DD;text-align:right;padding-bottom:13px;text-decoration:underline"><a href="https://github.com/homotechsual/Blog-Scripts/blob/main/Update%20Management/CVE202241099Downloader.ps1" class="githubLink" style="margin:0 10px" target="_blank">View on GitHub</a></div></div><p>:::note Change Logs</p><h4 class="anchor anchorTargetStickyNavbar_Vzrq" id="version-14-1">Version: 1.4<a href="https://homotechsual.dev/2023/01/17/Download-CVE-2022-41099-Patches#version-14-1" class="hash-link" aria-label="Direct link to Version: 1.4" title="Direct link to Version: 1.4" translate="no">​</a></h4><p>Empty the patch folder if it's not empty. Thanks to Wisecompany for the suggestion.</p><h4 class="anchor anchorTargetStickyNavbar_Vzrq" id="version-13-1">Version: 1.3<a href="https://homotechsual.dev/2023/01/17/Download-CVE-2022-41099-Patches#version-13-1" class="hash-link" aria-label="Direct link to Version: 1.3" title="Direct link to Version: 1.3" translate="no">​</a></h4><p>Use <code>$ProgressPreference</code> to speed up execution. Thanks to <a href="https://github.com/CodyRWhite" target="_blank" rel="noopener noreferrer" class="">https://github.com/CodyRWhite</a> for the suggestion.</p><h4 class="anchor anchorTargetStickyNavbar_Vzrq" id="version-12-1">Version: 1.2<a href="https://homotechsual.dev/2023/01/17/Download-CVE-2022-41099-Patches#version-12-1" class="hash-link" aria-label="Direct link to Version: 1.2" title="Direct link to Version: 1.2" translate="no">​</a></h4><p>Fix a bug on line 82 where a hashtable of architectures was attempted to be accessed using the Windows build number. Thanks to Sir Loin of House WinAdmins for spotting this. (Yes, it's a Game of Thrones reference. So original.)</p><h4 class="anchor anchorTargetStickyNavbar_Vzrq" id="version-11-1">Version: 1.1<a href="https://homotechsual.dev/2023/01/17/Download-CVE-2022-41099-Patches#version-11-1" class="hash-link" aria-label="Direct link to Version: 1.1" title="Direct link to Version: 1.1" translate="no">​</a></h4><p>Adds handling for 19044.</p><h4 class="anchor anchorTargetStickyNavbar_Vzrq" id="version-10-1">Version: 1.0<a href="https://homotechsual.dev/2023/01/17/Download-CVE-2022-41099-Patches#version-10-1" class="hash-link" aria-label="Direct link to Version: 1.0" title="Direct link to Version: 1.0" translate="no">​</a></h4><p>Initial release.</p><p>:::</p></div></div></details>
<h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="examples">Examples<a href="https://homotechsual.dev/2023/01/17/Download-CVE-2022-41099-Patches#examples" class="hash-link" aria-label="Direct link to Examples" title="Direct link to Examples" translate="no">​</a></h3>
<p>This example will download the applicable patch and SSU (if applicable) for CVE-2022-41099 to the folder C:\RMM\CVEs\2022-41099.</p>
<div class="language-powershell codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#9CDCFE;--prism-background-color:#1E1E1E"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-powershell codeBlock_bY9V thin-scrollbar" style="color:#9CDCFE;background-color:#1E1E1E"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#9CDCFE"><span class="token plain">Get-CVE202241099Patches</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><span class="token plain">ps1 </span><span class="token operator" style="color:rgb(212, 212, 212)">-</span><span class="token plain">PatchFolder </span><span class="token string" style="color:rgb(206, 145, 120)">'C:\RMM\CVEs\2022-41099\'</span><br></div></code></pre></div></div>
<p>This example will download all patches for CVE-2022-41099 to the folder C:\RMM\CVEs\2022-41099. With subfolders for each KB and architecture.</p>
<div class="language-powershell codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#9CDCFE;--prism-background-color:#1E1E1E"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-powershell codeBlock_bY9V thin-scrollbar" style="color:#9CDCFE;background-color:#1E1E1E"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#9CDCFE"><span class="token plain">Get-CVE202241099Patches</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><span class="token plain">ps1 </span><span class="token operator" style="color:rgb(212, 212, 212)">-</span><span class="token plain">PatchFolder </span><span class="token string" style="color:rgb(206, 145, 120)">'C:\RMM\CVEs\2022-41099\'</span><span class="token plain"> </span><span class="token operator" style="color:rgb(212, 212, 212)">-</span><span class="token plain">All</span><br></div></code></pre></div></div>
<h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="validating-the-fix">Validating the Fix<a href="https://homotechsual.dev/2023/01/17/Download-CVE-2022-41099-Patches#validating-the-fix" class="hash-link" aria-label="Direct link to Validating the Fix" title="Direct link to Validating the Fix" translate="no">​</a></h3>
<p>By popular request you can validate the fix using the principles in the script used for <a class="" href="https://homotechsual.dev/2024/02/13/CVE-Monitoring-NinjaOne#cve-2022-41099">CVE detection</a>.</p>
<span class="hero__wrapper"><section class="post__hero hero shadow--md bordered"><div class="container"><h2 class="hero__title"><strong>Collaboration with Martin Himken</strong></h2><p class="hero__subtitle">This post and the WinRE patching script on Martin's blog at https://manima.de are the result of a collaboration between Martin and I to help mutually improve our various efforts towards patching CVE-2022-41099.</p><div class="hero__button"><a class="button button--primary button--outline button--lg" href="https://manima.de/2023/01/modify-winre-patches-drivers-and-cve-2022-41099/">Read Martin's blog on WinRE patching</a></div></div></section></span>]]></content:encoded>
            <category>Collaboration</category>
            <category>Vulnerability</category>
            <category>Security</category>
            <category>Windows</category>
            <category>CVE</category>
            <category>PowerShell</category>
        </item>
        <item>
            <title><![CDATA[Sending Toast Notifications in Windows 10 and 11]]></title>
            <link>https://homotechsual.dev/2023/01/17/Toast-Notifications-Windows-10-and-11</link>
            <guid>https://homotechsual.dev/2023/01/17/Toast-Notifications-Windows-10-and-11</guid>
            <pubDate>Tue, 17 Jan 2023 12:00:00 GMT</pubDate>
            <description><![CDATA[<CodeSource]]></description>
            <content:encoded><![CDATA[<span class="hero__wrapper"><section class="post__hero hero shadow--md bordered"><div class="container"><h2 class="hero__title"><strong>This post uses code in part from the SMSAgent Blog.</strong></h2><p class="hero__subtitle">This post takes a snippet from the SMSAgent Blog and adds some additional magic along with two new custom functions.</p><div class="hero__button"><a class="button button--primary button--outline button--lg" href="https://smsagent.blog/2020/10/20/adding-your-own-caller-app-for-custom-windows-10-toast-notifications/">View the original post</a></div></div></section></span>
<p>If you're a Windows 10 or 11 user you'll be familiar with the toast notifications that appear in the bottom right of your screen. These are a great way to get a quick message to the user without interrupting what they're doing. In this article we'll look at how to send a toast notification from PowerShell.</p>
<p>We could use the excellent <a href="https://toastit.dev/" target="_blank" rel="noopener noreferrer" class="">BurntToast</a> PowerShell module to send a toast notification, but in the interests of reducing the number of third-party modules installed on client machines we'll be using the underlying .NET APIs directly as our needs are fairly simple.</p>
<p>Sending toast notifications is fairly simple once you get to grips with the underlying XML schema but we want our Toasts to be next-level so we're going to make them</p>
<!-- -->
<details class="details_lb9f alert alert--info details_b_Ee" data-collapsed="true"><summary><h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="creating-a-notification-app">Creating a Notification App<a href="https://homotechsual.dev/2023/01/17/Toast-Notifications-Windows-10-and-11#creating-a-notification-app" class="hash-link" aria-label="Direct link to Creating a Notification App" title="Direct link to Creating a Notification App" translate="no">​</a></h2></summary><div><div class="collapsibleContent_i85q"><p>This script takes a few parameters to create a Notification App. The App Name and Icon are the most important as these are what will appear in the toast notification.</p><p>Parameter documentation follows:</p><table><thead><tr><th>Parameter</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td>IconURI</td><td>URI</td><td>The URI of the app icon to use for the notification app registration. This will be downloaded to the working directory.</td></tr><tr><td>IconFileName</td><td>String</td><td>File name to use for the app icon. Optional. If not specified, the file name from the URI will be used.</td></tr><tr><td>WorkingDirectory</td><td>DirectoryInfo</td><td>The working directory to use for the app icon. If not specified, 'C:\RMM\NotificationApp' will be used.</td></tr><tr><td>AppId</td><td>String</td><td>The app ID to use for the notification app registration. Expected format is something like: 'CompanyName.AppName'.</td></tr><tr><td>AppDisplayName</td><td>String</td><td>The app display name to use for the notification app registration.</td></tr><tr><td>AppIconBackgroundColor</td><td>String</td><td>The background color to use for the app icon. Optional. If not specified, the background color will be transparent. Expected format is a hex value like 'FF000000' or '0' for transparent.</td></tr><tr><td>ShowInSettings</td><td>Int</td><td>Show the app in the Windows Settings app. Optional. If not specified, the app will not be shown in the Settings app.</td></tr></tbody></table><h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="the-script">The Script<a href="https://homotechsual.dev/2023/01/17/Toast-Notifications-Windows-10-and-11#the-script" class="hash-link" aria-label="Direct link to The Script" title="Direct link to The Script" translate="no">​</a></h3><div class="docusaurus-theme-github-codeblock"><div class="language-powershell codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#9CDCFE;--prism-background-color:#1E1E1E"><div class="codeBlockTitle_OeMC">New-NotificationApp.ps1</div><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-powershell codeBlock_bY9V thin-scrollbar" style="color:#9CDCFE;background-color:#1E1E1E"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#9CDCFE"><span class="token plain">loading</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><br></div></code></pre></div></div><div style="font-size:.9em;font-weight:600;color:#0E75DD;text-align:right;padding-bottom:13px;text-decoration:underline"><a href="https://github.com/homotechsual/Blog-Scripts/blob/main/Utilities/Windows/Notifications/RegisterNotificationApp.ps1" class="githubLink" style="margin:0 10px" target="_blank">View on GitHub</a></div></div><h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="generic-example">Generic Example<a href="https://homotechsual.dev/2023/01/17/Toast-Notifications-Windows-10-and-11#generic-example" class="hash-link" aria-label="Direct link to Generic Example" title="Direct link to Generic Example" translate="no">​</a></h3><div class="language-powershell codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#9CDCFE;--prism-background-color:#1E1E1E"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-powershell codeBlock_bY9V thin-scrollbar" style="color:#9CDCFE;background-color:#1E1E1E"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#9CDCFE"><span class="token comment" style="color:rgb(106, 153, 85)"># Setup parameter hashtable.</span><span class="token plain"></span><br></div><div class="token-line" style="color:#9CDCFE"><span class="token plain"></span><span class="token variable" style="color:rgb(156, 220, 254)">$NotificationAppParams</span><span class="token plain"> = @</span><span class="token punctuation" style="color:rgb(212, 212, 212)">{</span><span class="token plain"></span><br></div><div class="token-line" style="color:#9CDCFE"><span class="token plain">  IconURI = </span><span class="token string" style="color:rgb(206, 145, 120)">'https://homotechsual.dev/img/Icon.png'</span><span class="token plain"></span><br></div><div class="token-line" style="color:#9CDCFE"><span class="token plain">  IconFileName = </span><span class="token string" style="color:rgb(206, 145, 120)">'homotechsual.png'</span><span class="token plain"></span><br></div><div class="token-line" style="color:#9CDCFE"><span class="token plain">  WorkingDirectory = </span><span class="token string" style="color:rgb(206, 145, 120)">'C:\RMM\NotificationApp'</span><span class="token plain"></span><br></div><div class="token-line" style="color:#9CDCFE"><span class="token plain">  AppId = </span><span class="token string" style="color:rgb(206, 145, 120)">'homotechsual.example'</span><span class="token plain"></span><br></div><div class="token-line" style="color:#9CDCFE"><span class="token plain">  AppDisplayName = </span><span class="token string" style="color:rgb(206, 145, 120)">'Homotechsual Example'</span><span class="token plain"></span><br></div><div class="token-line" style="color:#9CDCFE"><span class="token plain">  AppIconBackgroundColor = 0</span><br></div><div class="token-line" style="color:#9CDCFE"><span class="token plain">  ShowInSettings = 1</span><br></div><div class="token-line" style="color:#9CDCFE"><span class="token plain"></span><span class="token punctuation" style="color:rgb(212, 212, 212)">}</span><span class="token plain"></span><br></div><div class="token-line" style="color:#9CDCFE"><span class="token plain"></span><span class="token function" style="color:rgb(220, 220, 170)">Register-NotificationApp</span><span class="token plain"> @NotificationAppParams</span><br></div></code></pre></div></div><h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="rmm-example">RMM Example<a href="https://homotechsual.dev/2023/01/17/Toast-Notifications-Windows-10-and-11#rmm-example" class="hash-link" aria-label="Direct link to RMM Example" title="Direct link to RMM Example" translate="no">​</a></h3><p>Unsurprisingly, I'm going to use NinjaOne as the example RMM here. So I've done the donkeywork that is best documented by NinjaOne themselves on the <a href="https://ninjarmm.zendesk.com/" target="_blank" rel="noopener noreferrer" class="">Dojo</a> and added the script above to the NinjaOne Script Library - but what next?</p><h4 class="anchor anchorTargetStickyNavbar_Vzrq" id="option-1-same-app-for-all-customers">Option 1: Same App for All Customers<a href="https://homotechsual.dev/2023/01/17/Toast-Notifications-Windows-10-and-11#option-1-same-app-for-all-customers" class="hash-link" aria-label="Direct link to Option 1: Same App for All Customers" title="Direct link to Option 1: Same App for All Customers" translate="no">​</a></h4><p>Well the chances are that you want to use the same relatively small set of apps per customer so we'll just store a nice blob of text in the Ninja Script Library.</p><p>We could end up with a "Preset Parameter" set like this:</p><p><code>-IconURI https://homotechsual.dev/img/Icon.png -IconFileName homotechsual.png -WorkingDirectory C:\RMM\NotificationApp -AppId homotechsual.example -AppDisplayName "Homotechsual Example" -AppIconBackgroundColor 0 -ShowInSettings 1</code></p><p>You can have multiple preset parameter sets and simply select the one you want to use when you run the script or when you schedule it against a group (or however you want to run this) but what about getting more creative?</p><h4 class="anchor anchorTargetStickyNavbar_Vzrq" id="option-2-pull-app-details-per-customer">Option 2: Pull App Details per Customer<a href="https://homotechsual.dev/2023/01/17/Toast-Notifications-Windows-10-and-11#option-2-pull-app-details-per-customer" class="hash-link" aria-label="Direct link to Option 2: Pull App Details per Customer" title="Direct link to Option 2: Pull App Details per Customer" translate="no">​</a></h4><p>We can use Documentation fields to store the details of the app per client and then use the NinjaOne CLI to pull the details when we run the script. This is a little more work but it's worth it if you want to brand your notifications per customer.</p><p>We'll need to add a few fields to the NinjaOne Documentation tab for each client:</p><table><thead><tr><th>Field</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td>NotificationIconURI</td><td>URL</td><td>The URI of the app icon to use for the notification app registration. This will be downloaded to the working directory.</td></tr><tr><td>NotificationAppId</td><td>String</td><td>The app ID to use for the notification app registration. Expected format is something like: 'CompanyName.AppName'.</td></tr><tr><td>NotificationAppDisplayName</td><td>String</td><td>The app display name to use for the notification app registration.</td></tr><tr><td>NotificationAppBackgroundColor</td><td>String</td><td>The background color to use for the app icon. Optional. If not specified, the background color will be transparent. Expected format is a hex value like 'FF000000' or '0' for transparent.</td></tr></tbody></table><p>We can then use the NinjaOne CLI to pull the details for the client we're running the script against and use them to create the parameter set for the script.</p><p>This means editing our script a little to accept the parameters from the CLI and then using the NinjaOne CLI to pull the details from the Documentation tab. We're going to assume you called your Document Template <code>Example Template</code> and your fields named as above in the table (with spaces between words if you wish).</p><p>At the top of the script we're going to replace the entire parameter block:</p><div class="theme-tabs-container tabs-container tabList__CuJ"><ul role="tablist" aria-orientation="horizontal" class="tabs"><li role="tab" tabindex="0" aria-selected="true" class="tabs__item tabItem_LNqP tabs__item--active">Before</li><li role="tab" tabindex="-1" aria-selected="false" class="tabs__item tabItem_LNqP">After</li></ul><div class="margin-top--md"><div role="tabpanel" class="tabItem_Ymn6"><div class="language-powershell codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#9CDCFE;--prism-background-color:#1E1E1E"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-powershell codeBlock_bY9V thin-scrollbar" style="color:#9CDCFE;background-color:#1E1E1E"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#9CDCFE"><span class="token namespace">[CmdletBinding()]</span><span class="token plain"></span><br></div><div class="token-line" style="color:#9CDCFE"><span class="token plain"></span><span class="token keyword" style="color:rgb(86, 156, 214)">Param</span><span class="token punctuation" style="color:rgb(212, 212, 212)">(</span><span class="token plain"></span><br></div><div class="token-line" style="color:#9CDCFE"><span class="token plain">    </span><span class="token comment" style="color:rgb(106, 153, 85)"># The URI of the app icon to use for the notification app registration.</span><span class="token plain"></span><br></div><div class="token-line" style="color:#9CDCFE"><span class="token plain">    </span><span class="token namespace">[Parameter(Mandatory)]</span><span class="token plain"></span><br></div><div class="token-line" style="color:#9CDCFE"><span class="token plain">    </span><span class="token namespace">[uri]</span><span class="token variable" style="color:rgb(156, 220, 254)">$IconURI</span><span class="token punctuation" style="color:rgb(212, 212, 212)">,</span><span class="token plain"></span><br></div><div class="token-line" style="color:#9CDCFE"><span class="token plain">    </span><span class="token comment" style="color:rgb(106, 153, 85)"># File name to use for the app icon. Optional. If not specified, the file name from the URI will be used.</span><span class="token plain"></span><br></div><div class="token-line" style="color:#9CDCFE"><span class="token plain">    </span><span class="token namespace">[string]</span><span class="token variable" style="color:rgb(156, 220, 254)">$IconFileName</span><span class="token punctuation" style="color:rgb(212, 212, 212)">,</span><span class="token plain"></span><br></div><div class="token-line" style="color:#9CDCFE"><span class="token plain">    </span><span class="token comment" style="color:rgb(106, 153, 85)"># The working directory to use for the app icon. If not specified, 'C:\RMM\NotificationApp\' will be used.</span><span class="token plain"></span><br></div><div class="token-line" style="color:#9CDCFE"><span class="token plain">    </span><span class="token namespace">[System.IO.DirectoryInfo]</span><span class="token variable" style="color:rgb(156, 220, 254)">$WorkingDirectory</span><span class="token plain"> = </span><span class="token string" style="color:rgb(206, 145, 120)">'C:\RMM\NotificationApp\'</span><span class="token punctuation" style="color:rgb(212, 212, 212)">,</span><span class="token plain"></span><br></div><div class="token-line" style="color:#9CDCFE"><span class="token plain">    </span><span class="token comment" style="color:rgb(106, 153, 85)"># The app ID to use for the notification app registration. Expected format is something like: 'CompanyName.AppName'.</span><span class="token plain"></span><br></div><div class="token-line" style="color:#9CDCFE"><span class="token plain">    </span><span class="token namespace">[Parameter(Mandatory)]</span><span class="token plain"></span><br></div><div class="token-line" style="color:#9CDCFE"><span class="token plain">    </span><span class="token namespace">[string]</span><span class="token variable" style="color:rgb(156, 220, 254)">$AppId</span><span class="token punctuation" style="color:rgb(212, 212, 212)">,</span><span class="token plain"></span><br></div><div class="token-line" style="color:#9CDCFE"><span class="token plain">    </span><span class="token comment" style="color:rgb(106, 153, 85)"># The app display name to use for the notification app registration.</span><span class="token plain"></span><br></div><div class="token-line" style="color:#9CDCFE"><span class="token plain">    </span><span class="token namespace">[Parameter(Mandatory)]</span><span class="token plain"></span><br></div><div class="token-line" style="color:#9CDCFE"><span class="token plain">    </span><span class="token namespace">[string]</span><span class="token variable" style="color:rgb(156, 220, 254)">$AppDisplayName</span><span class="token punctuation" style="color:rgb(212, 212, 212)">,</span><span class="token plain"></span><br></div><div class="token-line" style="color:#9CDCFE"><span class="token plain">    </span><span class="token comment" style="color:rgb(106, 153, 85)"># The background color to use for the app icon. Optional. If not specified, the background color will be transparent. Expected format is a hex value like 'FF000000' or '0' for transparent.</span><span class="token plain"></span><br></div><div class="token-line" style="color:#9CDCFE"><span class="token plain">    </span><span class="token punctuation" style="color:rgb(212, 212, 212)">[</span><span class="token plain">ValidatePattern</span><span class="token punctuation" style="color:rgb(212, 212, 212)">(</span><span class="token string" style="color:rgb(206, 145, 120)">'^(0)$|^([A-F0-9]{8})$'</span><span class="token punctuation" style="color:rgb(212, 212, 212)">)</span><span class="token punctuation" style="color:rgb(212, 212, 212)">]</span><span class="token plain"></span><br></div><div class="token-line" style="color:#9CDCFE"><span class="token plain">    </span><span class="token namespace">[string]</span><span class="token variable" style="color:rgb(156, 220, 254)">$AppIconBackgroundColor</span><span class="token plain"> = 0</span><span class="token punctuation" style="color:rgb(212, 212, 212)">,</span><span class="token plain"></span><br></div><div class="token-line" style="color:#9CDCFE"><span class="token plain">    </span><span class="token comment" style="color:rgb(106, 153, 85)"># Whether or not to show the app in the Windows Settings app. Optional. If not specified, the app will not be shown in the Settings app. Expected values are 0 or 1 (0 = false, 1 = true).</span><span class="token plain"></span><br></div><div class="token-line" style="color:#9CDCFE"><span class="token plain">    </span><span class="token namespace">[int]</span><span class="token variable" style="color:rgb(156, 220, 254)">$ShowInSettings</span><span class="token plain"> = 0</span><br></div><div class="token-line" style="color:#9CDCFE"><span class="token plain"></span><span class="token punctuation" style="color:rgb(212, 212, 212)">)</span><br></div></code></pre></div></div></div><div role="tabpanel" class="tabItem_Ymn6" hidden=""><p>And replace it with this:</p><div class="language-powershell codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#9CDCFE;--prism-background-color:#1E1E1E"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-powershell codeBlock_bY9V thin-scrollbar" style="color:#9CDCFE;background-color:#1E1E1E"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#9CDCFE"><span class="token variable" style="color:rgb(156, 220, 254)">$IconURI</span><span class="token plain"> = Ninja-Docs-Property-Get </span><span class="token string" style="color:rgb(206, 145, 120)">"Example Template"</span><span class="token plain"> </span><span class="token string" style="color:rgb(206, 145, 120)">"NotificationIconURI"</span><span class="token plain"></span><br></div><div class="token-line" style="color:#9CDCFE"><span class="token plain"></span><span class="token variable" style="color:rgb(156, 220, 254)">$IconFileName</span><span class="token plain"> = </span><span class="token string" style="color:rgb(206, 145, 120)">'NotificationIcon.png'</span><span class="token plain"></span><br></div><div class="token-line" style="color:#9CDCFE"><span class="token plain"></span><span class="token variable" style="color:rgb(156, 220, 254)">$WorkingDirectory</span><span class="token plain"> = </span><span class="token string" style="color:rgb(206, 145, 120)">'C:\RMM\NotificationApp\'</span><span class="token plain"></span><br></div><div class="token-line" style="color:#9CDCFE"><span class="token plain"></span><span class="token variable" style="color:rgb(156, 220, 254)">$AppId</span><span class="token plain"> = Ninja-Docs-Property-Get </span><span class="token string" style="color:rgb(206, 145, 120)">"Example Template"</span><span class="token plain"> </span><span class="token string" style="color:rgb(206, 145, 120)">"NotificationAppId"</span><span class="token plain"></span><br></div><div class="token-line" style="color:#9CDCFE"><span class="token plain"></span><span class="token variable" style="color:rgb(156, 220, 254)">$AppDisplayName</span><span class="token plain"> = Ninja-Docs-Property-Get </span><span class="token string" style="color:rgb(206, 145, 120)">"Example Template"</span><span class="token plain"> </span><span class="token string" style="color:rgb(206, 145, 120)">"NotificationAppDisplayName"</span><span class="token plain"></span><br></div><div class="token-line" style="color:#9CDCFE"><span class="token plain"></span><span class="token variable" style="color:rgb(156, 220, 254)">$AppIconBackgroundColor</span><span class="token plain"> = Ninja-Docs-Property-Get </span><span class="token string" style="color:rgb(206, 145, 120)">"Example Template"</span><span class="token plain"> </span><span class="token string" style="color:rgb(206, 145, 120)">"NotificationAppBackgroundColor"</span><span class="token plain"></span><br></div><div class="token-line" style="color:#9CDCFE"><span class="token plain"></span><span class="token variable" style="color:rgb(156, 220, 254)">$ShowInSettings</span><span class="token plain"> = 1</span><br></div></code></pre></div></div><p>If done correctly, you should be able to run the script and have it pull the details from the Documentation tab for the client you're running it against. This could be improved by exiting the script if the required fields are not populated so we could add something like this after <code>$ShowInSettings = 1</code>:</p><div class="language-powershell codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#9CDCFE;--prism-background-color:#1E1E1E"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-powershell codeBlock_bY9V thin-scrollbar" style="color:#9CDCFE;background-color:#1E1E1E"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#9CDCFE"><span class="token keyword" style="color:rgb(86, 156, 214)">if</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(212, 212, 212)">(</span><span class="token punctuation" style="color:rgb(212, 212, 212)">(</span><span class="token variable" style="color:rgb(156, 220, 254)">$null</span><span class="token plain"> </span><span class="token operator" style="color:rgb(212, 212, 212)">-eq</span><span class="token plain"> </span><span class="token variable" style="color:rgb(156, 220, 254)">$IconURI</span><span class="token punctuation" style="color:rgb(212, 212, 212)">)</span><span class="token plain"> </span><span class="token operator" style="color:rgb(212, 212, 212)">-or</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(212, 212, 212)">(</span><span class="token variable" style="color:rgb(156, 220, 254)">$null</span><span class="token plain"> </span><span class="token operator" style="color:rgb(212, 212, 212)">-eq</span><span class="token plain"> </span><span class="token variable" style="color:rgb(156, 220, 254)">$AppId</span><span class="token punctuation" style="color:rgb(212, 212, 212)">)</span><span class="token plain"> </span><span class="token operator" style="color:rgb(212, 212, 212)">-or</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(212, 212, 212)">(</span><span class="token variable" style="color:rgb(156, 220, 254)">$null</span><span class="token plain"> </span><span class="token operator" style="color:rgb(212, 212, 212)">-eq</span><span class="token plain"> </span><span class="token variable" style="color:rgb(156, 220, 254)">$AppDisplayName</span><span class="token punctuation" style="color:rgb(212, 212, 212)">)</span><span class="token punctuation" style="color:rgb(212, 212, 212)">)</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(212, 212, 212)">{</span><span class="token plain"></span><br></div><div class="token-line" style="color:#9CDCFE"><span class="token plain">    </span><span class="token function" style="color:rgb(220, 220, 170)">Write-Error</span><span class="token plain"> </span><span class="token string" style="color:rgb(206, 145, 120)">"Required fields are not populated in the Documentation tab."</span><span class="token plain"></span><br></div><div class="token-line" style="color:#9CDCFE"><span class="token plain">    </span><span class="token keyword" style="color:rgb(86, 156, 214)">exit</span><span class="token plain"></span><br></div><div class="token-line" style="color:#9CDCFE"><span class="token plain"></span><span class="token punctuation" style="color:rgb(212, 212, 212)">}</span><br></div></code></pre></div></div></div></div></div></div></div></details>
<p>Well that's setting up the notification app registration. Now we need to actually send a notification using the app.</p>
<details class="details_lb9f alert alert--info details_b_Ee" data-collapsed="true"><summary><h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="sending-a-notification">Sending a Notification<a href="https://homotechsual.dev/2023/01/17/Toast-Notifications-Windows-10-and-11#sending-a-notification" class="hash-link" aria-label="Direct link to Sending a Notification" title="Direct link to Sending a Notification" translate="no">​</a></h2></summary><div><div class="collapsibleContent_i85q"><p>So this is an entirely separate script - you can use it with the custom app you just created or you can use it with the default where notifications come from Windows PowerShell. It's up to you.</p><p>:::tip "Runs as User"
This script runs in the user's context it is unlikely it'll work running as Administrator or as a scheduled task. If you want to run it as a scheduled task, you'll need to use something like <a href="https://github.com/KelvinTegelaar/RunAsUser" target="_blank" rel="noopener noreferrer" class="">RunAsUser</a> to run it as the user.
:::</p><p>This script takes a few parameters to create a Notification App. The App Name and Icon are the most important as these are what will appear in the toast notification.</p><p>Parameter documentation follows:</p><table><thead><tr><th>Parameter</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td>AppId</td><td>String</td><td>The app ID to use for the notification app registration. Expected format is something like: 'CompanyName.AppName'.</td></tr><tr><td>NotificationImage</td><td>String</td><td>The path to the image to use for the notification.</td></tr><tr><td>NotificationTitle</td><td>String</td><td>The title to use for the notification.</td></tr><tr><td>NotificationMessage</td><td>String</td><td>The message text to use for the notification.</td></tr><tr><td>NotificationType</td><td>String</td><td>The type of notification to send. Expected values are <code>alarm</code>, <code>reminder</code>, <code>incomingcall</code> or <code>default</code>. Details on what each type looks like can be found <a href="https://learn.microsoft.com/en-us/windows/apps/design/shell/tiles-and-notifications/toast-schema#toastscenario" target="_blank" rel="noopener noreferrer" class="">in Microsoft's Toast schema</a>.</td></tr></tbody></table><h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="the-script-1">The Script<a href="https://homotechsual.dev/2023/01/17/Toast-Notifications-Windows-10-and-11#the-script-1" class="hash-link" aria-label="Direct link to The Script" title="Direct link to The Script" translate="no">​</a></h3><div class="docusaurus-theme-github-codeblock"><div class="language-powershell codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#9CDCFE;--prism-background-color:#1E1E1E"><div class="codeBlockTitle_OeMC">Send-SimpleNotification.ps1</div><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-powershell codeBlock_bY9V thin-scrollbar" style="color:#9CDCFE;background-color:#1E1E1E"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#9CDCFE"><span class="token plain">loading</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><br></div></code></pre></div></div><div style="font-size:.9em;font-weight:600;color:#0E75DD;text-align:right;padding-bottom:13px;text-decoration:underline"><a href="https://github.com/homotechsual/Blog-Scripts/blob/main/Utilities/Windows/Notifications/SendNotificationSimple.ps1" class="githubLink" style="margin:0 10px" target="_blank">View on GitHub</a></div></div><h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="generic-example-1">Generic Example<a href="https://homotechsual.dev/2023/01/17/Toast-Notifications-Windows-10-and-11#generic-example-1" class="hash-link" aria-label="Direct link to Generic Example" title="Direct link to Generic Example" translate="no">​</a></h3><div class="language-powershell codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#9CDCFE;--prism-background-color:#1E1E1E"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-powershell codeBlock_bY9V thin-scrollbar" style="color:#9CDCFE;background-color:#1E1E1E"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#9CDCFE"><span class="token comment" style="color:rgb(106, 153, 85)"># Setup parameter hashtable.</span><span class="token plain"></span><br></div><div class="token-line" style="color:#9CDCFE"><span class="token plain"></span><span class="token variable" style="color:rgb(156, 220, 254)">$NotificationParams</span><span class="token plain"> = @</span><span class="token punctuation" style="color:rgb(212, 212, 212)">{</span><span class="token plain"></span><br></div><div class="token-line" style="color:#9CDCFE"><span class="token plain">  AppId = </span><span class="token string" style="color:rgb(206, 145, 120)">'homotechsual.example'</span><span class="token plain"></span><br></div><div class="token-line" style="color:#9CDCFE"><span class="token plain">  NotificationImage = </span><span class="token string" style="color:rgb(206, 145, 120)">'C:\RMM\NotificationApp\NotificationIcon.png'</span><span class="token plain"></span><br></div><div class="token-line" style="color:#9CDCFE"><span class="token plain">  NotificationTitle = </span><span class="token string" style="color:rgb(206, 145, 120)">'Example Notification'</span><span class="token plain"></span><br></div><div class="token-line" style="color:#9CDCFE"><span class="token plain">  NotificationMessage = </span><span class="token string" style="color:rgb(206, 145, 120)">'This is an example notification.'</span><span class="token plain"></span><br></div><div class="token-line" style="color:#9CDCFE"><span class="token plain">  NotificationType = </span><span class="token string" style="color:rgb(206, 145, 120)">'reminder'</span><span class="token plain"></span><br></div><div class="token-line" style="color:#9CDCFE"><span class="token plain"></span><span class="token punctuation" style="color:rgb(212, 212, 212)">}</span><span class="token plain"></span><br></div><div class="token-line" style="color:#9CDCFE"><span class="token plain"></span><span class="token function" style="color:rgb(220, 220, 170)">Send-Notification</span><span class="token plain"> @NotificationParams</span><br></div></code></pre></div></div><h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="script-example">Script Example<a href="https://homotechsual.dev/2023/01/17/Toast-Notifications-Windows-10-and-11#script-example" class="hash-link" aria-label="Direct link to Script Example" title="Direct link to Script Example" translate="no">​</a></h3><p>It's probably most useful to use this script as part of a larger script. For example, you could use it to send a notification when a script has finished running. You could also use it to send a notification when a scheduled task has finished running.</p><div class="docusaurus-theme-github-codeblock"><div class="language-powershell codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#9CDCFE;--prism-background-color:#1E1E1E"><div class="codeBlockTitle_OeMC">NotificationExample.ps1</div><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-powershell codeBlock_bY9V thin-scrollbar" style="color:#9CDCFE;background-color:#1E1E1E"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#9CDCFE"><span class="token plain">loading</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><br></div></code></pre></div></div><div style="font-size:.9em;font-weight:600;color:#0E75DD;text-align:right;padding-bottom:13px;text-decoration:underline"><a href="https://github.com/homotechsual/Blog-Scripts/blob/main/Utilities/Windows/Notifications/NotificationExample.ps1" class="githubLink" style="margin:0 10px" target="_blank">View on GitHub</a></div></div><p>This would output something like this:</p><p><img decoding="async" loading="lazy" alt="Example Notification" src="https://homotechsual.dev/assets/images/PrinterSpoolerNotification-b714f40621697563d740a056cac74ec1.png" width="366" height="107" class="img_ev3q"></p></div></div></details>
<p>There are many other ways you could use notifications and you can add (and handle) actions within notifications but I'm spoiling some killer upcoming blog posts.</p>]]></content:encoded>
            <category>Notifications</category>
            <category>User Experience</category>
            <category>Windows</category>
            <category>Client Management</category>
            <category>PowerShell</category>
        </item>
        <item>
            <title><![CDATA[Updating Drivers from Microsoft Update]]></title>
            <link>https://homotechsual.dev/2023/01/10/Updating-Drivers-from-Microsoft-Update</link>
            <guid>https://homotechsual.dev/2023/01/10/Updating-Drivers-from-Microsoft-Update</guid>
            <pubDate>Tue, 10 Jan 2023 00:00:00 GMT</pubDate>
            <description><![CDATA[Creating Fields]]></description>
            <content:encoded><![CDATA[<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="creating-fields">Creating Fields<a href="https://homotechsual.dev/2023/01/10/Updating-Drivers-from-Microsoft-Update#creating-fields" class="hash-link" aria-label="Direct link to Creating Fields" title="Direct link to Creating Fields" translate="no">​</a></h2>
<div class="theme-admonition theme-admonition-ninja admonition_Gfwi alert alert--ninja"><div class="admonitionHeading_f1Ed"><span class="admonitionIcon_kpSf"><svg data-prefix="fas" data-icon="user-ninja" class="svg-inline--fa fa-user-ninja" role="img" viewBox="0 0 448 512" aria-hidden="true"><path fill="currentColor" d="M352 128c0 70.7-57.3 128-128 128-57.2 0-105.6-37.5-122-89.3-1.1 1.3-2.2 2.6-3.5 3.8-15.8 15.8-38.8 20.7-53.6 22.1-8.1 .8-14.6-5.7-13.8-13.8 1.4-14.7 6.3-37.8 22.1-53.6 5.8-5.8 12.6-10.1 19.6-13.4-7-3.2-13.8-7.6-19.6-13.4-15.8-15.8-20.7-38.8-22.1-53.6-.8-8.1 5.7-14.6 13.8-13.8 14.7 1.4 37.8 6.3 53.6 22.1 4.8 4.8 8.7 10.4 11.7 16.1 21.3-41.2 64.3-69.4 113.8-69.4 70.7 0 128 57.3 128 128zM144 112c0 8.8 7.2 16 16 16l128 0c8.8 0 16-7.2 16-16s-7.2-16-16-16L160 96c-8.8 0-16 7.2-16 16zm-1.4 211l67 50.2c8.5 6.4 20.3 6.4 28.8 0l67-50.2c6.5-4.9 15.2-6.2 22.6-2.8 61.4 28.2 104.1 90.2 104.1 162.1 0 16.4-13.3 29.7-29.7 29.7L45.7 512c-16.4 0-29.7-13.3-29.7-29.7 0-72 42.7-134 104.1-162.1 7.4-3.4 16.1-2.1 22.6 2.8z"></path></svg></span>Creating custom fields in NinjaOne</div><div class="admonitionContent_UjKb">To create a custom field in NinjaOne go to <b>Administration <!-- -->&gt;<!-- --> Devices</b> and select either <b>Role Custom Fields</b> or <b>Global Custom Fields</b> then select <b>Add</b>.<br><br><ul><li>Role Custom Fields are custom fields that are specific to a device role.</li><li>Global Custom Fields are custom fields that are applicable to all devices and/or to a location and/or organisation</li></ul>Make sure you add the fields to the roles you want to use them in at <b>Administration <!-- -->&gt;<!-- --> Devices <!-- -->&gt;<!-- --> Roles</b> (for role custom fields).<br><br>When you create your custom field you need to make sure that you set the <b>Scripts</b> permission to ensure that you can read or write to the field from your scripts - as appropriate for the script you're using.</div></div>
<p>We're adding three role custom fields for devices with the <em>Windows Laptop</em> role:</p>
<table><thead><tr><th>Field Name</th><th>Field Type</th><th>Description</th></tr></thead><tbody><tr><td>Driver Update: Reboot Required</td><td>Checkbox</td><td>Whether the latest driver update run requires a reboot to finalise.</td></tr><tr><td>Driver Update: Last Run</td><td>Date/Time</td><td>The date and time the driver update script last ran successfully.</td></tr><tr><td>Driver Update: Number Installed on Last Run</td><td>Integer</td><td>The number of driver updates installed on last script run.</td></tr></tbody></table>
<!-- -->
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="the-script">The Script<a href="https://homotechsual.dev/2023/01/10/Updating-Drivers-from-Microsoft-Update#the-script" class="hash-link" aria-label="Direct link to The Script" title="Direct link to The Script" translate="no">​</a></h2>
<div class="docusaurus-theme-github-codeblock"><div class="language-powershell codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#9CDCFE;--prism-background-color:#1E1E1E"><div class="codeBlockTitle_OeMC">Invoke-MUDriverUpdater.ps1</div><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-powershell codeBlock_bY9V thin-scrollbar" style="color:#9CDCFE;background-color:#1E1E1E"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#9CDCFE"><span class="token plain">loading</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><br></div></code></pre></div></div><div style="font-size:.9em;font-weight:600;color:#0E75DD;text-align:right;padding-bottom:13px;text-decoration:underline"><a href="https://github.com/homotechsual/Blog-Scripts/blob/main/Update%20Management/MUDriverUpdater.ps1" class="githubLink" style="margin:0 10px" target="_blank">View on GitHub</a></div></div>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="the-results">The Results<a href="https://homotechsual.dev/2023/01/10/Updating-Drivers-from-Microsoft-Update#the-results" class="hash-link" aria-label="Direct link to The Results" title="Direct link to The Results" translate="no">​</a></h2>
<p><img decoding="async" loading="lazy" alt="Driver Update Related Custom Fields" src="https://homotechsual.dev/assets/images/NinjaOneDriverUpdaterFields-aa888452f77bcfad2bd7f678f12cba37.png" width="1511" height="198" class="img_ev3q"></p>
<p>You can set this up to run on a schedule - we run this script immediately on machine onboarding and then every 7 days on a Tuesday. This doesn't always have anything to do as our Windows Update run usually handles these updates, but it's a good way to ensure that we're always up to date with the latest drivers from Microsoft Update.</p>]]></content:encoded>
            <category>Updates</category>
            <category>NinjaOne</category>
            <category>Custom Fields</category>
            <category>PowerShell</category>
        </item>
        <item>
            <title><![CDATA[NinjaOne custom fields - exploring endless possibilities]]></title>
            <link>https://homotechsual.dev/2022/12/22/NinjaOne-custom-fields-endless-possibilities</link>
            <guid>https://homotechsual.dev/2022/12/22/NinjaOne-custom-fields-endless-possibilities</guid>
            <pubDate>Thu, 22 Dec 2022 00:00:00 GMT</pubDate>
            <description><![CDATA[<CodeSource]]></description>
            <content:encoded><![CDATA[<span class="hero__wrapper"><section class="post__hero hero shadow--md bordered"><div class="container"><h2 class="hero__title"><strong>This post uses code from CyberDrain</strong></h2><p class="hero__subtitle">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.</p><div class="hero__button"><a class="button button--primary button--outline button--lg" href="https://www.cyberdrain.com/">Flush me down the CyberDrain</a></div></div></section></span>
<p>You will find more excellent uses for NinjaOne custom fields on the <a href="https://ninjarmm.zendesk.com/?source=homotechsual" target="_blank" rel="noopener noreferrer" class="">Dojo</a>, on <a href="https://techfoundry.co.uk/?source=homotechsual" target="_blank" rel="noopener noreferrer" class="">Stephen Murphy's blog</a> and on <a href="https://mspp.io/?source=homotechsual" target="_blank" rel="noopener noreferrer" class="">Luke Whitelock's blog</a>.</p>
<p>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.</p>
<p>This post was updated on 2022/12/22 to add a new script to run a speedtest on a device and store the results in NinjaOne.</p>
<!-- -->
<details class="details_lb9f alert alert--info details_b_Ee" data-collapsed="true"><summary><h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="battery-health">Battery Health<a href="https://homotechsual.dev/2022/12/22/NinjaOne-custom-fields-endless-possibilities#battery-health" class="hash-link" aria-label="Direct link to Battery Health" title="Direct link to Battery Health" translate="no">​</a></h2></summary><div><div class="collapsibleContent_i85q"><h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="creating-fields">Creating Fields<a href="https://homotechsual.dev/2022/12/22/NinjaOne-custom-fields-endless-possibilities#creating-fields" class="hash-link" aria-label="Direct link to Creating Fields" title="Direct link to Creating Fields" translate="no">​</a></h3><div class="theme-admonition theme-admonition-ninja admonition_Gfwi alert alert--ninja"><div class="admonitionHeading_f1Ed"><span class="admonitionIcon_kpSf"><svg data-prefix="fas" data-icon="user-ninja" class="svg-inline--fa fa-user-ninja" role="img" viewBox="0 0 448 512" aria-hidden="true"><path fill="currentColor" d="M352 128c0 70.7-57.3 128-128 128-57.2 0-105.6-37.5-122-89.3-1.1 1.3-2.2 2.6-3.5 3.8-15.8 15.8-38.8 20.7-53.6 22.1-8.1 .8-14.6-5.7-13.8-13.8 1.4-14.7 6.3-37.8 22.1-53.6 5.8-5.8 12.6-10.1 19.6-13.4-7-3.2-13.8-7.6-19.6-13.4-15.8-15.8-20.7-38.8-22.1-53.6-.8-8.1 5.7-14.6 13.8-13.8 14.7 1.4 37.8 6.3 53.6 22.1 4.8 4.8 8.7 10.4 11.7 16.1 21.3-41.2 64.3-69.4 113.8-69.4 70.7 0 128 57.3 128 128zM144 112c0 8.8 7.2 16 16 16l128 0c8.8 0 16-7.2 16-16s-7.2-16-16-16L160 96c-8.8 0-16 7.2-16 16zm-1.4 211l67 50.2c8.5 6.4 20.3 6.4 28.8 0l67-50.2c6.5-4.9 15.2-6.2 22.6-2.8 61.4 28.2 104.1 90.2 104.1 162.1 0 16.4-13.3 29.7-29.7 29.7L45.7 512c-16.4 0-29.7-13.3-29.7-29.7 0-72 42.7-134 104.1-162.1 7.4-3.4 16.1-2.1 22.6 2.8z"></path></svg></span>Creating custom fields in NinjaOne</div><div class="admonitionContent_UjKb">To create a custom field in NinjaOne go to <b>Administration <!-- -->&gt;<!-- --> Devices</b> and select either <b>Role Custom Fields</b> or <b>Global Custom Fields</b> then select <b>Add</b>.<br><br><ul><li>Role Custom Fields are custom fields that are specific to a device role.</li><li>Global Custom Fields are custom fields that are applicable to all devices and/or to a location and/or organisation</li></ul>Make sure you add the fields to the roles you want to use them in at <b>Administration <!-- -->&gt;<!-- --> Devices <!-- -->&gt;<!-- --> Roles</b> (for role custom fields).<br><br>When you create your custom field you need to make sure that you set the <b>Scripts</b> permission to ensure that you can read or write to the field from your scripts - as appropriate for the script you're using.</div></div><p>We're adding seven role custom fields for devices with the <em>Windows Laptop</em> role:</p><table><thead><tr><th>Field Name</th><th>Field Type</th><th>Description</th></tr></thead><tbody><tr><td>Has Batteries</td><td>Checkbox</td><td>Whether the device has batteries</td></tr><tr><td>Battery Identifier</td><td>Text</td><td>The ID of the battery being reported on.</td></tr><tr><td>Battery Design Capacity</td><td>Integer</td><td>The original design capacity of the laptop's battery.</td></tr><tr><td>Battery Full Charge Capacity</td><td>Integer</td><td>The current fully charged capacity of the laptop's battery.</td></tr><tr><td>Battery Health Percent</td><td>Integer</td><td>The current percentage of battery health.</td></tr><tr><td>Battery Cycle Count</td><td>Integer</td><td>The number of times the battery has been cycled. That is drained fully and charged.</td></tr><tr><td>Additional Battery</td><td>Checkbox</td><td>The system has an additional battery, only the first is reported in the fields above.</td></tr></tbody></table><h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="the-script">The Script<a href="https://homotechsual.dev/2022/12/22/NinjaOne-custom-fields-endless-possibilities#the-script" class="hash-link" aria-label="Direct link to The Script" title="Direct link to The Script" translate="no">​</a></h3><div class="theme-admonition theme-admonition-ninja admonition_Gfwi alert alert--ninja"><div class="admonitionHeading_f1Ed"><span class="admonitionIcon_kpSf"><svg data-prefix="fas" data-icon="user-ninja" class="svg-inline--fa fa-user-ninja" role="img" viewBox="0 0 448 512" aria-hidden="true"><path fill="currentColor" d="M352 128c0 70.7-57.3 128-128 128-57.2 0-105.6-37.5-122-89.3-1.1 1.3-2.2 2.6-3.5 3.8-15.8 15.8-38.8 20.7-53.6 22.1-8.1 .8-14.6-5.7-13.8-13.8 1.4-14.7 6.3-37.8 22.1-53.6 5.8-5.8 12.6-10.1 19.6-13.4-7-3.2-13.8-7.6-19.6-13.4-15.8-15.8-20.7-38.8-22.1-53.6-.8-8.1 5.7-14.6 13.8-13.8 14.7 1.4 37.8 6.3 53.6 22.1 4.8 4.8 8.7 10.4 11.7 16.1 21.3-41.2 64.3-69.4 113.8-69.4 70.7 0 128 57.3 128 128zM144 112c0 8.8 7.2 16 16 16l128 0c8.8 0 16-7.2 16-16s-7.2-16-16-16L160 96c-8.8 0-16 7.2-16 16zm-1.4 211l67 50.2c8.5 6.4 20.3 6.4 28.8 0l67-50.2c6.5-4.9 15.2-6.2 22.6-2.8 61.4 28.2 104.1 90.2 104.1 162.1 0 16.4-13.3 29.7-29.7 29.7L45.7 512c-16.4 0-29.7-13.3-29.7-29.7 0-72 42.7-134 104.1-162.1 7.4-3.4 16.1-2.1 22.6 2.8z"></path></svg></span>Working on it</div><div class="admonitionContent_UjKb">Ninja have confirmed that they are working on native functionality which will replace this script. Stay tuned to Ninja's release notes on the [NinjaOne Dojo](https://ninjarmm.zendesk.com) for more information.</div></div><div class="theme-admonition theme-admonition-tip admonition_Gfwi alert alert--success"><div class="admonitionHeading_f1Ed"><span class="admonitionIcon_kpSf"><svg data-prefix="fas" data-icon="lightbulb" class="svg-inline--fa fa-lightbulb" role="img" viewBox="0 0 384 512" aria-hidden="true"><path fill="currentColor" d="M292.9 384c7.3-22.3 21.9-42.5 38.4-59.9 32.7-34.4 52.7-80.9 52.7-132.1 0-106-86-192-192-192S0 86 0 192c0 51.2 20 97.7 52.7 132.1 16.5 17.4 31.2 37.6 38.4 59.9l201.7 0zM288 432l-192 0 0 16c0 44.2 35.8 80 80 80l32 0c44.2 0 80-35.8 80-80l0-16zM184 112c-39.8 0-72 32.2-72 72 0 13.3-10.7 24-24 24s-24-10.7-24-24c0-66.3 53.7-120 120-120 13.3 0 24 10.7 24 24s-10.7 24-24 24z"></path></svg></span>This Script Was Updated</div><div class="admonitionContent_UjKb"><p>This script was updated after being published, if you're using it please compare the version you have with the version available here.</p><p>This script was last updated on <!-- -->2022/03/26<!-- -->.</p></div></div><p>This script accepts a single parameter to set the data storage directory for the script. This is where the script will store the battery information it gathers. The script will create the directory if it doesn't exist. The default is <code>C:\RMM\Data</code> use parameter <code>-OutputPath</code> to override.</p><div class="docusaurus-theme-github-codeblock"><div class="language-powershell codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#9CDCFE;--prism-background-color:#1E1E1E"><div class="codeBlockTitle_OeMC">Get-BatteryHealth.ps1</div><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-powershell codeBlock_bY9V thin-scrollbar" style="color:#9CDCFE;background-color:#1E1E1E"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#9CDCFE"><span class="token plain">loading</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><br></div></code></pre></div></div><div style="font-size:.9em;font-weight:600;color:#0E75DD;text-align:right;padding-bottom:13px;text-decoration:underline"><a href="https://github.com/homotechsual/Blog-Scripts/blob/main/Monitoring/BatteryHealth.ps1" class="githubLink" style="margin:0 10px" target="_blank">View on GitHub</a></div></div><p><strong>Source:</strong> <a href="https://www.cyberdrain.com/monitoring-with-powershell-monitoring-battery-health/" target="_blank" rel="noopener noreferrer" class="">https://www.cyberdrain.com/monitoring-with-powershell-monitoring-battery-health/</a></p><h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="the-results">The Results<a href="https://homotechsual.dev/2022/12/22/NinjaOne-custom-fields-endless-possibilities#the-results" class="hash-link" aria-label="Direct link to The Results" title="Direct link to The Results" translate="no">​</a></h3><p><img decoding="async" loading="lazy" alt="Battery Related Custom Fields" src="https://homotechsual.dev/assets/images/NinjaOneBatteryFields-1ab6723b12e30865ae01cb8719680f10.png" width="240" height="425" class="img_ev3q"></p><p>You can set this up to run on a schedule - we run this script monthly to keep up-to-date battery information in NinjaOne.</p></div></div></details>
<details class="details_lb9f alert alert--info details_b_Ee" data-collapsed="true"><summary><h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="domain-join-status">Domain Join Status<a href="https://homotechsual.dev/2022/12/22/NinjaOne-custom-fields-endless-possibilities#domain-join-status" class="hash-link" aria-label="Direct link to Domain Join Status" title="Direct link to Domain Join Status" translate="no">​</a></h2></summary><div><div class="collapsibleContent_i85q"><h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="creating-fields-1">Creating Fields<a href="https://homotechsual.dev/2022/12/22/NinjaOne-custom-fields-endless-possibilities#creating-fields-1" class="hash-link" aria-label="Direct link to Creating Fields" title="Direct link to Creating Fields" translate="no">​</a></h3><div class="theme-admonition theme-admonition-ninja admonition_Gfwi alert alert--ninja"><div class="admonitionHeading_f1Ed"><span class="admonitionIcon_kpSf"><svg data-prefix="fas" data-icon="user-ninja" class="svg-inline--fa fa-user-ninja" role="img" viewBox="0 0 448 512" aria-hidden="true"><path fill="currentColor" d="M352 128c0 70.7-57.3 128-128 128-57.2 0-105.6-37.5-122-89.3-1.1 1.3-2.2 2.6-3.5 3.8-15.8 15.8-38.8 20.7-53.6 22.1-8.1 .8-14.6-5.7-13.8-13.8 1.4-14.7 6.3-37.8 22.1-53.6 5.8-5.8 12.6-10.1 19.6-13.4-7-3.2-13.8-7.6-19.6-13.4-15.8-15.8-20.7-38.8-22.1-53.6-.8-8.1 5.7-14.6 13.8-13.8 14.7 1.4 37.8 6.3 53.6 22.1 4.8 4.8 8.7 10.4 11.7 16.1 21.3-41.2 64.3-69.4 113.8-69.4 70.7 0 128 57.3 128 128zM144 112c0 8.8 7.2 16 16 16l128 0c8.8 0 16-7.2 16-16s-7.2-16-16-16L160 96c-8.8 0-16 7.2-16 16zm-1.4 211l67 50.2c8.5 6.4 20.3 6.4 28.8 0l67-50.2c6.5-4.9 15.2-6.2 22.6-2.8 61.4 28.2 104.1 90.2 104.1 162.1 0 16.4-13.3 29.7-29.7 29.7L45.7 512c-16.4 0-29.7-13.3-29.7-29.7 0-72 42.7-134 104.1-162.1 7.4-3.4 16.1-2.1 22.6 2.8z"></path></svg></span>Creating custom fields in NinjaOne</div><div class="admonitionContent_UjKb">To create a custom field in NinjaOne go to <b>Administration <!-- -->&gt;<!-- --> Devices</b> and select either <b>Role Custom Fields</b> or <b>Global Custom Fields</b> then select <b>Add</b>.<br><br><ul><li>Role Custom Fields are custom fields that are specific to a device role.</li><li>Global Custom Fields are custom fields that are applicable to all devices and/or to a location and/or organisation</li></ul>Make sure you add the fields to the roles you want to use them in at <b>Administration <!-- -->&gt;<!-- --> Devices <!-- -->&gt;<!-- --> Roles</b> (for role custom fields).<br><br>When you create your custom field you need to make sure that you set the <b>Scripts</b> permission to ensure that you can read or write to the field from your scripts - as appropriate for the script you're using.</div></div><p>We're adding three role custom fields for devices with the <em>Windows Laptop</em> role:</p><table><thead><tr><th>Field Name</th><th>Field Type</th><th>Description</th></tr></thead><tbody><tr><td>Domain Join Status</td><td>Drop-down</td><td>The current domain join status of the device.</td></tr><tr><td>Domain Name</td><td>Text</td><td>The name of the currently joined AD domain.</td></tr><tr><td>Tenant Name</td><td>Text</td><td>The name of the currently joined Azure AD tenant.</td></tr></tbody></table><p>The domain join status field should be configured with the following option values:</p><ul>
<li class="">Azure AD Domain</li>
<li class="">AD Domain</li>
<li class="">Hybrid Azure AD/AD Domain</li>
<li class="">On-premise DRS</li>
<li class="">No Domain</li>
</ul><h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="options">Options<a href="https://homotechsual.dev/2022/12/22/NinjaOne-custom-fields-endless-possibilities#options" class="hash-link" aria-label="Direct link to Options" title="Direct link to Options" translate="no">​</a></h3><p>We've created a dropdown field for this script, we can't set the options by name with these - so first we need to find out how NinjaOne wants us to give the selected option. To do that we're going to open a PowerShell session to any device in the role that has the field assigned and run:</p><div class="language-powershell codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#9CDCFE;--prism-background-color:#1E1E1E"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-powershell codeBlock_bY9V thin-scrollbar" style="color:#9CDCFE;background-color:#1E1E1E"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#9CDCFE"><span class="token function" style="color:rgb(220, 220, 170)">Set-ExecutionPolicy</span><span class="token plain"> </span><span class="token operator" style="color:rgb(212, 212, 212)">-</span><span class="token plain">Scope </span><span class="token keyword" style="color:rgb(86, 156, 214)">Process</span><span class="token plain"> </span><span class="token operator" style="color:rgb(212, 212, 212)">-</span><span class="token plain">ExecutionPolicy RemoteSigned</span><br></div><div class="token-line" style="color:#9CDCFE"><span class="token plain"></span><span class="token function" style="color:rgb(220, 220, 170)">Import-Module</span><span class="token plain"> NJCliPSh</span><br></div><div class="token-line" style="color:#9CDCFE"><span class="token plain">Ninja-Property-Options domainJoinStatus</span><br></div></code></pre></div></div><p>This will print a list that looks something like this:</p><blockquote>
<p>1989092a-1ae0-4e6e-b274-50ea9618d436=Azure AD Domain<br>
<!-- -->53745d33-fd5e-4c7d-bfd5-fea174a46781=No Domain<br>
<!-- -->bb4c5215-ead7-47a3-8f36-f711c81580ce=On-premises DRS<br>
<!-- -->c23486e9-49eb-4acb-8f9d-7f5d8711c284=AD Domain<br>
<!-- -->c6e7ef80-68a1-4591-8055-5cee585f4f79=Hybrid Azure AD/AD Domain</p>
</blockquote><p>When we want to pass the option to the field we need to use the GUID - for example <code>1989092a-1ae0-4e6e-b274-50ea9618d436</code> for Azure AD Domain.</p><h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="the-script-1">The Script<a href="https://homotechsual.dev/2022/12/22/NinjaOne-custom-fields-endless-possibilities#the-script-1" class="hash-link" aria-label="Direct link to The Script" title="Direct link to The Script" translate="no">​</a></h3><div class="theme-admonition theme-admonition-caution admonition_Gfwi alert alert--warning"><div class="admonitionHeading_f1Ed"><span class="admonitionIcon_kpSf"><svg data-prefix="fas" data-icon="triangle-exclamation" class="svg-inline--fa fa-triangle-exclamation" role="img" viewBox="0 0 512 512" aria-hidden="true"><path fill="currentColor" d="M256 0c14.7 0 28.2 8.1 35.2 21l216 400c6.7 12.4 6.4 27.4-.8 39.5S486.1 480 472 480L40 480c-14.1 0-27.2-7.4-34.4-19.5s-7.5-27.1-.8-39.5l216-400c7-12.9 20.5-21 35.2-21zm0 352a32 32 0 1 0 0 64 32 32 0 1 0 0-64zm0-192c-18.2 0-32.7 15.5-31.4 33.7l7.4 104c.9 12.5 11.4 22.3 23.9 22.3 12.6 0 23-9.7 23.9-22.3l7.4-104c1.3-18.2-13.1-33.7-31.4-33.7z"></path></svg></span>This Script Requires Input</div><div class="admonitionContent_UjKb">This script requires user input, whether in the form of variables, parameters or edits to the script itself before you can run it. Areas where you need to provide input will be indicated with:<div class="language-powershell codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#9CDCFE;--prism-background-color:#1E1E1E"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-powershell codeBlock_bY9V thin-scrollbar" style="color:#9CDCFE;background-color:#1E1E1E"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#9CDCFE"><span class="token comment" style="color:rgb(106, 153, 85)">### Inline Comments</span><br></div></code></pre></div></div>and / or<div class="language-powershell codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#9CDCFE;--prism-background-color:#1E1E1E"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-powershell codeBlock_bY9V thin-scrollbar" style="color:#9CDCFE;background-color:#1E1E1E"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#9CDCFE"><span class="token string" style="color:rgb(206, 145, 120)">'&lt;MARKED STRINGS&gt;'</span><br></div></code></pre></div></div>Parameters will be indicated before the script block.</div></div><div class="theme-admonition theme-admonition-tip admonition_Gfwi alert alert--success"><div class="admonitionHeading_f1Ed"><span class="admonitionIcon_kpSf"><svg data-prefix="fas" data-icon="lightbulb" class="svg-inline--fa fa-lightbulb" role="img" viewBox="0 0 384 512" aria-hidden="true"><path fill="currentColor" d="M292.9 384c7.3-22.3 21.9-42.5 38.4-59.9 32.7-34.4 52.7-80.9 52.7-132.1 0-106-86-192-192-192S0 86 0 192c0 51.2 20 97.7 52.7 132.1 16.5 17.4 31.2 37.6 38.4 59.9l201.7 0zM288 432l-192 0 0 16c0 44.2 35.8 80 80 80l32 0c44.2 0 80-35.8 80-80l0-16zM184 112c-39.8 0-72 32.2-72 72 0 13.3-10.7 24-24 24s-24-10.7-24-24c0-66.3 53.7-120 120-120 13.3 0 24 10.7 24 24s-10.7 24-24 24z"></path></svg></span>This Script Was Updated</div><div class="admonitionContent_UjKb"><p>This script was updated after being published, if you're using it please compare the version you have with the version available here.</p><p>This script was last updated on <!-- -->2022/05/25<!-- -->.</p></div></div><div class="docusaurus-theme-github-codeblock"><div class="language-powershell codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#9CDCFE;--prism-background-color:#1E1E1E"><div class="codeBlockTitle_OeMC">Get-DomainJoinStatus.ps1</div><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-powershell codeBlock_bY9V thin-scrollbar" style="color:#9CDCFE;background-color:#1E1E1E"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#9CDCFE"><span class="token plain">loading</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><br></div></code></pre></div></div><div style="font-size:.9em;font-weight:600;color:#0E75DD;text-align:right;padding-bottom:13px;text-decoration:underline"><a href="https://github.com/homotechsual/Blog-Scripts/blob/main/Monitoring/DomainJoin.ps1" class="githubLink" style="margin:0 10px" target="_blank">View on GitHub</a></div></div><h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="the-results-1">The Results<a href="https://homotechsual.dev/2022/12/22/NinjaOne-custom-fields-endless-possibilities#the-results-1" class="hash-link" aria-label="Direct link to The Results" title="Direct link to The Results" translate="no">​</a></h3><p><img decoding="async" loading="lazy" alt="Domain Related Custom Fields" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAOkAAACtCAYAAABV/liZAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAACXhSURBVHhe7d0PXBR1/j/wV7qwLH9W1kVZYFFYEJBV+eNKYGiIHmIghxWGf7L60cOj4uyr30v7nt5XuvTO4r7ZmXd5pZVaaUeXPjos5YwoSElQMQUU+ZetuKQriCAgi/0+MzsgKCJ/ddD308c8mPnM7OzMOO/5vD+zs599QOXs8gsIIaI1RPhLCBEpClJCRI6ClBCRoyAlROQoSAkROQpSQkSOgpQQkaMgJUTkKEgJEbleP3EksbOBytZCmOqEqQGG800wCZOiZmUDtYLtS2Md9NUdt1g+wh5ySTNqz9ejdlDsDLnX9DpIvea+gKRAhTDVict52Lh2L4qFybtK7YloX3vgigHfZutRKxS3mbYQG2a6sZELyNq4Cal6czGgwqKVz0JnV428LX/DttNCMSF3UK/T3SuGChSXlZgHVsvwTNXQt5ZVVOGKufTuGxOMiPBIRDw8joVdVxwwZV4Y1MIUIWIw1NZOniyM90jtj6dx6PAJ82DliVmerKaqL8C2N3fjS67suIGvsWSaAMyPjURs7DSEjlNi2IVyFFdf49fhFxOPOBY4o6+WwyIoAk/NiUZYgBIyw2mUXuIX4TkGheHJOTMQ+0gQdF6OUFT3YB3jQ5EUOgZKG0u2tzI4e46EtPI0yuv4l5u5TzBvP8d6FMbbFyOjkFvAFn5TA+EsbUTl0Vwcu8iKJPYIiZ2F+Y/MQsxUH/i4SVBzuhJGPhW2R/iCWESFjIZtVTXGzJ6LhTE6jB9Ri9Kii1CFR2Hx3FjMmKiA9Fz7fZTAa2oE4n49A3Ez/B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L0277OVIGtW/fC4LEQr/HH4GUk+FxCRq87LjNgz9cFkIUk4Q12DN5YtxQRDaX00MI9aHD3cdTvHZvdGbd+NLE3Bs8jmaR3qCMyQkSubx/BEEIGHAUpISJHQUqIyFGQEiJyFKSEiBwFKSEiR0FKiMhRkBIichSkhIgcBSkhIkdBSojIUZASInIUpISIGvD/AanbOQ/PnTRJAAAAAElFTkSuQmCC" width="233" height="173" class="img_ev3q"></p><p>You can set this up to run on a schedule - we run this script monthly to keep up-to-date domain information in NinjaOne.</p></div></div></details>
<details class="details_lb9f alert alert--info details_b_Ee" data-collapsed="true"><summary><h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="autopilot-hardware-identifier">Autopilot Hardware Identifier<a href="https://homotechsual.dev/2022/12/22/NinjaOne-custom-fields-endless-possibilities#autopilot-hardware-identifier" class="hash-link" aria-label="Direct link to Autopilot Hardware Identifier" title="Direct link to Autopilot Hardware Identifier" translate="no">​</a></h2></summary><div><div class="collapsibleContent_i85q"><h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="creating-fields-2">Creating Fields<a href="https://homotechsual.dev/2022/12/22/NinjaOne-custom-fields-endless-possibilities#creating-fields-2" class="hash-link" aria-label="Direct link to Creating Fields" title="Direct link to Creating Fields" translate="no">​</a></h3><div class="theme-admonition theme-admonition-ninja admonition_Gfwi alert alert--ninja"><div class="admonitionHeading_f1Ed"><span class="admonitionIcon_kpSf"><svg data-prefix="fas" data-icon="user-ninja" class="svg-inline--fa fa-user-ninja" role="img" viewBox="0 0 448 512" aria-hidden="true"><path fill="currentColor" d="M352 128c0 70.7-57.3 128-128 128-57.2 0-105.6-37.5-122-89.3-1.1 1.3-2.2 2.6-3.5 3.8-15.8 15.8-38.8 20.7-53.6 22.1-8.1 .8-14.6-5.7-13.8-13.8 1.4-14.7 6.3-37.8 22.1-53.6 5.8-5.8 12.6-10.1 19.6-13.4-7-3.2-13.8-7.6-19.6-13.4-15.8-15.8-20.7-38.8-22.1-53.6-.8-8.1 5.7-14.6 13.8-13.8 14.7 1.4 37.8 6.3 53.6 22.1 4.8 4.8 8.7 10.4 11.7 16.1 21.3-41.2 64.3-69.4 113.8-69.4 70.7 0 128 57.3 128 128zM144 112c0 8.8 7.2 16 16 16l128 0c8.8 0 16-7.2 16-16s-7.2-16-16-16L160 96c-8.8 0-16 7.2-16 16zm-1.4 211l67 50.2c8.5 6.4 20.3 6.4 28.8 0l67-50.2c6.5-4.9 15.2-6.2 22.6-2.8 61.4 28.2 104.1 90.2 104.1 162.1 0 16.4-13.3 29.7-29.7 29.7L45.7 512c-16.4 0-29.7-13.3-29.7-29.7 0-72 42.7-134 104.1-162.1 7.4-3.4 16.1-2.1 22.6 2.8z"></path></svg></span>Creating custom fields in NinjaOne</div><div class="admonitionContent_UjKb">To create a custom field in NinjaOne go to <b>Administration <!-- -->&gt;<!-- --> Devices</b> and select either <b>Role Custom Fields</b> or <b>Global Custom Fields</b> then select <b>Add</b>.<br><br><ul><li>Role Custom Fields are custom fields that are specific to a device role.</li><li>Global Custom Fields are custom fields that are applicable to all devices and/or to a location and/or organisation</li></ul>Make sure you add the fields to the roles you want to use them in at <b>Administration <!-- -->&gt;<!-- --> Devices <!-- -->&gt;<!-- --> Roles</b> (for role custom fields).<br><br>When you create your custom field you need to make sure that you set the <b>Scripts</b> permission to ensure that you can read or write to the field from your scripts - as appropriate for the script you're using.</div></div><p>:::info "Field length"
Make sure when creating the custom field below that you set the character limit for the field to allow over 4000 characters using the "Advanced Settings" link on the field creation/edit page.</p><p><img decoding="async" loading="lazy" alt="Advanced Settings" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAI8AAAAkCAYAAACwuGm+AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAtoSURBVHhe7VsJVFTnFf5ghmER0EIEVBREARdQQzRG64ZGrJqSNCZttLExSV1OjZ7YaN0SWhOqRqNNE49N0pi1sYkmMUZxxYi4GySAQiAuiCCCw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8X3xl68uITguERVUI/EJcvOUcAwhsi/6d5q0t6Ibw/6ZwTZkW1CBT2ldh0/pJJdXVodha5KwkE552397N0zUh9PWVNKd5XZdlCDtMuPDNCTOioJPJ4OdJR2Dw0d1Vsj+OGoPLr64oOWNYHC6qDZb5TOnDEbrcdyHoYxhcGpkr6ygsOvtbqAa5vs+yp8D+GisTMNzsCGZxMpnM3ljjdkCHy9XSXLFw3gsf81AJy5pOIYyjnEzMivgaMcxo4SKer2TM35Gx+FGJrFd39ay2LeznkodxwTlt4oNFX3sdWutp70teDBb0EB9lDzEh4i5H6UjYcEIeFL04X1rSxY1uKP/e4JsQ8Zq/qACbMO2hrfX5iia96rd+W7neq3BczPhh6w/it9F+GHuhFCKNlb0fe0kVgwJwEuPRP4get4uWbR/vfmJgB2NU9+63d/SydcIb4Mec0YFYfrIIHls/zGgkecnBOYIp0L5XRjBPsX9GNDIo0E1HDptadBgD408GlRDI48G1dDIo0E1NPJoUA2NPBpUQyOPBtXQyKNBNTTyaFANjTwaVAL4Dxfc+ybzemk/AAAAAElFTkSuQmCC" width="143" height="36" class="img_ev3q">
<img decoding="async" loading="lazy" alt="Character Limit" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAjEAAABZCAYAAADPV3XqAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAABasSURBVHhe7d0JmI1l/wfw75iFmbHMWMcaKjK2RMo2hKiUtVdE15W1C1H9yZtSvCVL6S2RpNSb7FtZy5atBRlLQpixZqwZDMZs/O/vfc7DmcmMYWzH9f3UdOY86/08Z5rf99zP/ZzxSUxKuQARERERL5PN/SgiIiLiVRRiRERExCspxIiIiIhXUogRERERr6QQIyIiIl5JIUZERES8kkKMiIiIeCWFGBEREfFKCjEiIiLilRRiRERExCspxIiIiIhXUogRERERr6QQIyIiIl5JIUZERES8kkKMiIiIeCWFGBEREfFKCjF3iGzZssHXNxt8fHzcU+R60zkWEbm9ZDrE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FYdXX+2DuXPnom/fV3HgQIydzrDBYxozZgwCAwPx4Yf/NeFjPto9+yx+XLYcs2bN+ke7roTtYg9aq5bN0aD+IyYU5UX27Nnd83ywbNky8zP1I2rXro3FixdhwjfjbS/TZ5+NtQGR5yaryxw4cMAGkIyOnT2MnnhuK1asiBAT2tavj/zHfBERubkunxoykJychLVr19rLACxGLAY///yTKbJ+5pe8axnWNBbffv3eQMNHH8X9VaqhdevWmD59hi1460zRbdHiabz//nC7jc2bt6DV060xePCQVEWYWCi++GIcWrVqhTp16qJly1b45psJdp4TKLJnD8Cgd4egbt26aNqsmR0bQtz2/v370b3Hi6hdJwI1atRE+/bt7aUDrvfbb7+hWbMW+OST0ejatav5vrkJGWcwYcJE25tUrnxlM60Z/vOfd2y44P74OGzY+2jatBnqRNRFmzZtsHDhQvibkDFixAgsX74cOXPmROnwB0xQmG6ncwxFly5dULNmLdSsVRsvv/yKDRBXagOP9b7wSmjUqLE9lzynqQODD44cOYJDhw6haNGitofE8/zx+8JhhbFy1c+214UKFSqAKlWq4FzCOXtuD5l2sCftwQer4YkmTewyjRo1QoUK5W0A+vvvv7Fv3z7s2rXb9jzUqlXLntcWLVsivNx9tv0MUp7Ncl4Xzy9PbBfbumHTZttjlZziCgPcbkJCIlavXo1cuXKhc+dOCAoKQpky95rz0hSxscexbds2EyCTs7zMn3/+ac9bRsfOc+t5vnlq2W722PB88HVK/XqIiMjNdFUh5nhsLJ56qim2bN1uxxmwNv388884EBNjCm7Liz0T/L0+btw4O4bm1T6vInLdGvc74M+wc+dOe+mgXr26mDFjpi0W3333re3Ob9u2rS1kDhY/vtP/+OORuO+++zB27Bjb1f9vU9CXLl2KYBMWWJy+/PIr5M2bF2++2R95TZGZY95RcwwPLycwHJww7R7z6WjMnzfX9ix88MF/7WUDXrpgsZs0aRLKli1rix2Pa9q0aaawPYid27fgySefxLx58zF//nzTNh98/vnneH3gEDRs2ACjR4+Cv38AOnTqij+2bLPjUSpVqmx7Tr6d/D8TWmri8JFj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PP4ldu3ajSJEiiN4dbce2OA4fPgQfn2zIkSMHQkNDkTMo0F6GcnAwcOT6jcidO3eG8zlPRERE7ly+b741YKD7+3T5+PjYoMHxK1ejTu1aaN6s6cWvOrVq4HTcaXw+9lMULMixLDmwd+8+HDt6HOHh99k7ioa9PxwN69dHlSr328tMZ8/Gm+DzKx6sVg3nz5/H1+PHo9Rdd6FBg/rInj0g3fkNGzb4R6+PiIiI3H5OnopDrly53M8y76ZX+Zw5OXDXhWNeOnfuhOhd0fhX67Zo3eZZhJcrhyefbGLnMzw1a/YUcpsDa9mqNVqYLw4G7tjxeXu56UrzRURE5M7lk5iUcsVRsAwLMTExKFG8qHvK9cfxLb6+fv8c5OvGz4RJSUlOdSeSpyvNFxERkdvTvv0H7BATfrr/1bhtrrcwfKQXYIjzMgooV5ovIiIidxYNGhERERGvpBAjIiIiXkkhRkRERLySQoyIiIh4JYUYERER8UoKMSIiIuKVFGJERETEK2U6xPADaPix/iIiIiLXC7PF1X7InSPTISYoKAjHY08oyIiIiMh1wUzBbMGMcS0y9WcHiH96IDY21v6RRn4vIiIikhXsgWGACQ0NvabemEyHGFJ4ERERkevtWi8nXVWIEREREbld6O4kERER8UoKMSIiIuKVFGJERETEKynEiIiIiFdSiBERERGvpBAjIiIiXkkhRkRERLySQoyIiIh4JYUYERER8UoKMSIiIuKVFGJERETEKynEiIiIiFdSiBERERGvpBAjIiIiXkkhRkRERLwQ8P+uP5UGqGD0wwAAAABJRU5ErkJggg==" width="561" height="89" class="img_ev3q">
:::</p><p>We're adding one role custom field for devices with the <em>Windows Desktops and Laptops</em> role:</p><table><thead><tr><th>Field Name</th><th>Field Type</th><th>Description</th></tr></thead><tbody><tr><td>Autopilot HWID</td><td>Secure</td><td>The autopilot hardware identifier.</td></tr></tbody></table><h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="the-script-2">The Script<a href="https://homotechsual.dev/2022/12/22/NinjaOne-custom-fields-endless-possibilities#the-script-2" class="hash-link" aria-label="Direct link to The Script" title="Direct link to The Script" translate="no">​</a></h3><div class="docusaurus-theme-github-codeblock"><div class="language-powershell codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#9CDCFE;--prism-background-color:#1E1E1E"><div class="codeBlockTitle_OeMC">Get-AutopilotHWID.ps1</div><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-powershell codeBlock_bY9V thin-scrollbar" style="color:#9CDCFE;background-color:#1E1E1E"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#9CDCFE"><span class="token plain">loading</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><br></div></code></pre></div></div><div style="font-size:.9em;font-weight:600;color:#0E75DD;text-align:right;padding-bottom:13px;text-decoration:underline"><a href="https://github.com/homotechsual/Blog-Scripts/blob/main/Data%20Gathering/AutopilotHWID.ps1" class="githubLink" style="margin:0 10px" target="_blank">View on GitHub</a></div></div><h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="the-results-2">The Results<a href="https://homotechsual.dev/2022/12/22/NinjaOne-custom-fields-endless-possibilities#the-results-2" class="hash-link" aria-label="Direct link to The Results" title="Direct link to The Results" translate="no">​</a></h3><p><img decoding="async" loading="lazy" alt="HWID Related Custom Fields" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAANAAAABLCAYAAAABBQn0AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAqfSURBVHhe7d0NTJT3HQfw79YzcB5QDSCHPeyBcghKAXe2mIm2hKhR2+nibWyadk2NcYa4rJ3WRRNoipnWJd0s3YzRNH1baSSZ3dS0XUutODGR1WOT1yIgXipvF6yIB+PM9n95Du6Og3t5EI7t90kuz//+9+eeR3i+z//lzrvv6Oc/8h8QQkLyXWVLCAkBBYgQFShAhKhAASJEBQoQISpQgAhRgQJEiAoUIEJUoAARokLg70TQRCA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GhBD+HcT2K5rCx7Cdetu8ffVy4GR4a0h8JDwpKqd2MT8v8urF8HIiTcUYAIUYECRIgKFCBCVKAAEaICBYgQFShAhKhAASJEBQoQISpQgAhRgQJEiAoUIEJUoAARogIFiBAVKECEqEABIkQFChAhKlCACFGBAkRIyID/AvegeHqekb8UAAAAAElFTkSuQmCC" width="208" height="75" class="img_ev3q"></p><p>We run this after hardware changes or post onboarding.</p></div></div></details>
<details class="details_lb9f alert alert--info details_b_Ee" data-collapsed="true"><summary><h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="wireless-lan-monitoring">Wireless LAN Monitoring<a href="https://homotechsual.dev/2022/12/22/NinjaOne-custom-fields-endless-possibilities#wireless-lan-monitoring" class="hash-link" aria-label="Direct link to Wireless LAN Monitoring" title="Direct link to Wireless LAN Monitoring" translate="no">​</a></h2></summary><div><div class="collapsibleContent_i85q"><h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="creating-fields-3">Creating Fields<a href="https://homotechsual.dev/2022/12/22/NinjaOne-custom-fields-endless-possibilities#creating-fields-3" class="hash-link" aria-label="Direct link to Creating Fields" title="Direct link to Creating Fields" translate="no">​</a></h3><div class="theme-admonition theme-admonition-ninja admonition_Gfwi alert alert--ninja"><div class="admonitionHeading_f1Ed"><span class="admonitionIcon_kpSf"><svg data-prefix="fas" data-icon="user-ninja" class="svg-inline--fa fa-user-ninja" role="img" viewBox="0 0 448 512" aria-hidden="true"><path fill="currentColor" d="M352 128c0 70.7-57.3 128-128 128-57.2 0-105.6-37.5-122-89.3-1.1 1.3-2.2 2.6-3.5 3.8-15.8 15.8-38.8 20.7-53.6 22.1-8.1 .8-14.6-5.7-13.8-13.8 1.4-14.7 6.3-37.8 22.1-53.6 5.8-5.8 12.6-10.1 19.6-13.4-7-3.2-13.8-7.6-19.6-13.4-15.8-15.8-20.7-38.8-22.1-53.6-.8-8.1 5.7-14.6 13.8-13.8 14.7 1.4 37.8 6.3 53.6 22.1 4.8 4.8 8.7 10.4 11.7 16.1 21.3-41.2 64.3-69.4 113.8-69.4 70.7 0 128 57.3 128 128zM144 112c0 8.8 7.2 16 16 16l128 0c8.8 0 16-7.2 16-16s-7.2-16-16-16L160 96c-8.8 0-16 7.2-16 16zm-1.4 211l67 50.2c8.5 6.4 20.3 6.4 28.8 0l67-50.2c6.5-4.9 15.2-6.2 22.6-2.8 61.4 28.2 104.1 90.2 104.1 162.1 0 16.4-13.3 29.7-29.7 29.7L45.7 512c-16.4 0-29.7-13.3-29.7-29.7 0-72 42.7-134 104.1-162.1 7.4-3.4 16.1-2.1 22.6 2.8z"></path></svg></span>Creating custom fields in NinjaOne</div><div class="admonitionContent_UjKb">To create a custom field in NinjaOne go to <b>Administration <!-- -->&gt;<!-- --> Devices</b> and select either <b>Role Custom Fields</b> or <b>Global Custom Fields</b> then select <b>Add</b>.<br><br><ul><li>Role Custom Fields are custom fields that are specific to a device role.</li><li>Global Custom Fields are custom fields that are applicable to all devices and/or to a location and/or organisation</li></ul>Make sure you add the fields to the roles you want to use them in at <b>Administration <!-- -->&gt;<!-- --> Devices <!-- -->&gt;<!-- --> Roles</b> (for role custom fields).<br><br>When you create your custom field you need to make sure that you set the <b>Scripts</b> permission to ensure that you can read or write to the field from your scripts - as appropriate for the script you're using.</div></div><p>We're adding three role custom fields for devices with the <em>Windows Desktops and Laptops</em> role:</p><table><thead><tr><th>Field Name</th><th>Field Type</th><th>Description</th></tr></thead><tbody><tr><td>WLAN Disconnect Reasons</td><td>Multi-line</td><td>A list of the WLAN disconnect reasons with frequency. JSON</td></tr><tr><td>WLAN Failures</td><td>Integer</td><td>The number of WLAN failures in the report.</td></tr><tr><td>WLAN Warnings</td><td>Integer</td><td>The number of WLAN warnings in the report.</td></tr></tbody></table><h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="the-script-3">The Script<a href="https://homotechsual.dev/2022/12/22/NinjaOne-custom-fields-endless-possibilities#the-script-3" class="hash-link" aria-label="Direct link to The Script" title="Direct link to The Script" translate="no">​</a></h3><div class="docusaurus-theme-github-codeblock"><div class="language-powershell codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#9CDCFE;--prism-background-color:#1E1E1E"><div class="codeBlockTitle_OeMC">Get-WLANStatus.ps1</div><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-powershell codeBlock_bY9V thin-scrollbar" style="color:#9CDCFE;background-color:#1E1E1E"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#9CDCFE"><span class="token plain">loading</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><br></div></code></pre></div></div><div style="font-size:.9em;font-weight:600;color:#0E75DD;text-align:right;padding-bottom:13px;text-decoration:underline"><a href="https://github.com/homotechsual/Blog-Scripts/blob/main/Monitoring/WLANStatus.ps1" class="githubLink" style="margin:0 10px" target="_blank">View on GitHub</a></div></div><h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="the-results-3">The Results<a href="https://homotechsual.dev/2022/12/22/NinjaOne-custom-fields-endless-possibilities#the-results-3" class="hash-link" aria-label="Direct link to The Results" title="Direct link to The Results" translate="no">​</a></h3><p><img decoding="async" loading="lazy" alt="WLAN Related Custom Fields" src="https://homotechsual.dev/assets/images/NinjaOneWLANFields-b67c203d527a3489b68d5dc3114fafdc.png" width="638" height="692" class="img_ev3q"></p><p>You can set this up to run on a schedule - we run this script twice daily.</p></div></div></details>
<details class="details_lb9f alert alert--info details_b_Ee" data-collapsed="true"><summary><h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="windows-11-readiness">Windows 11 Readiness<a href="https://homotechsual.dev/2022/12/22/NinjaOne-custom-fields-endless-possibilities#windows-11-readiness" class="hash-link" aria-label="Direct link to Windows 11 Readiness" title="Direct link to Windows 11 Readiness" translate="no">​</a></h2></summary><div><div class="collapsibleContent_i85q"><h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="creating-fields-4">Creating Fields<a href="https://homotechsual.dev/2022/12/22/NinjaOne-custom-fields-endless-possibilities#creating-fields-4" class="hash-link" aria-label="Direct link to Creating Fields" title="Direct link to Creating Fields" translate="no">​</a></h3><div class="theme-admonition theme-admonition-ninja admonition_Gfwi alert alert--ninja"><div class="admonitionHeading_f1Ed"><span class="admonitionIcon_kpSf"><svg data-prefix="fas" data-icon="user-ninja" class="svg-inline--fa fa-user-ninja" role="img" viewBox="0 0 448 512" aria-hidden="true"><path fill="currentColor" d="M352 128c0 70.7-57.3 128-128 128-57.2 0-105.6-37.5-122-89.3-1.1 1.3-2.2 2.6-3.5 3.8-15.8 15.8-38.8 20.7-53.6 22.1-8.1 .8-14.6-5.7-13.8-13.8 1.4-14.7 6.3-37.8 22.1-53.6 5.8-5.8 12.6-10.1 19.6-13.4-7-3.2-13.8-7.6-19.6-13.4-15.8-15.8-20.7-38.8-22.1-53.6-.8-8.1 5.7-14.6 13.8-13.8 14.7 1.4 37.8 6.3 53.6 22.1 4.8 4.8 8.7 10.4 11.7 16.1 21.3-41.2 64.3-69.4 113.8-69.4 70.7 0 128 57.3 128 128zM144 112c0 8.8 7.2 16 16 16l128 0c8.8 0 16-7.2 16-16s-7.2-16-16-16L160 96c-8.8 0-16 7.2-16 16zm-1.4 211l67 50.2c8.5 6.4 20.3 6.4 28.8 0l67-50.2c6.5-4.9 15.2-6.2 22.6-2.8 61.4 28.2 104.1 90.2 104.1 162.1 0 16.4-13.3 29.7-29.7 29.7L45.7 512c-16.4 0-29.7-13.3-29.7-29.7 0-72 42.7-134 104.1-162.1 7.4-3.4 16.1-2.1 22.6 2.8z"></path></svg></span>Creating custom fields in NinjaOne</div><div class="admonitionContent_UjKb">To create a custom field in NinjaOne go to <b>Administration <!-- -->&gt;<!-- --> Devices</b> and select either <b>Role Custom Fields</b> or <b>Global Custom Fields</b> then select <b>Add</b>.<br><br><ul><li>Role Custom Fields are custom fields that are specific to a device role.</li><li>Global Custom Fields are custom fields that are applicable to all devices and/or to a location and/or organisation</li></ul>Make sure you add the fields to the roles you want to use them in at <b>Administration <!-- -->&gt;<!-- --> Devices <!-- -->&gt;<!-- --> Roles</b> (for role custom fields).<br><br>When you create your custom field you need to make sure that you set the <b>Scripts</b> permission to ensure that you can read or write to the field from your scripts - as appropriate for the script you're using.</div></div><p>We're adding two role custom fields for devices with the <em>Windows Desktops and Laptops</em> role:</p><table><thead><tr><th>Field Name</th><th>Field Type</th><th>Description</th></tr></thead><tbody><tr><td>Windows 11 Capable</td><td>Checkbox</td><td>Whether the device is Windows 11 capable as determined by our checks.</td></tr><tr><td>Windows 11 Readiness</td><td>WYSIWYG</td><td>The details checked to determine Windows 11 compatibility.</td></tr></tbody></table><h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="the-script-4">The Script<a href="https://homotechsual.dev/2022/12/22/NinjaOne-custom-fields-endless-possibilities#the-script-4" class="hash-link" aria-label="Direct link to The Script" title="Direct link to The Script" translate="no">​</a></h3><div class="theme-admonition theme-admonition-tip admonition_Gfwi alert alert--success"><div class="admonitionHeading_f1Ed"><span class="admonitionIcon_kpSf"><svg data-prefix="fas" data-icon="lightbulb" class="svg-inline--fa fa-lightbulb" role="img" viewBox="0 0 384 512" aria-hidden="true"><path fill="currentColor" d="M292.9 384c7.3-22.3 21.9-42.5 38.4-59.9 32.7-34.4 52.7-80.9 52.7-132.1 0-106-86-192-192-192S0 86 0 192c0 51.2 20 97.7 52.7 132.1 16.5 17.4 31.2 37.6 38.4 59.9l201.7 0zM288 432l-192 0 0 16c0 44.2 35.8 80 80 80l32 0c44.2 0 80-35.8 80-80l0-16zM184 112c-39.8 0-72 32.2-72 72 0 13.3-10.7 24-24 24s-24-10.7-24-24c0-66.3 53.7-120 120-120 13.3 0 24 10.7 24 24s-10.7 24-24 24z"></path></svg></span>This Script Was Updated</div><div class="admonitionContent_UjKb"><p>This script was updated after being published, if you're using it please compare the version you have with the version available here.</p><p>This script was last updated on <!-- -->2024/05/16<!-- -->.</p></div></div><div class="docusaurus-theme-github-codeblock"><div class="language-powershell codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#9CDCFE;--prism-background-color:#1E1E1E"><div class="codeBlockTitle_OeMC">Test-Windows11Readiness.ps1</div><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-powershell codeBlock_bY9V thin-scrollbar" style="color:#9CDCFE;background-color:#1E1E1E"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#9CDCFE"><span class="token plain">loading</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><br></div></code></pre></div></div><div style="font-size:.9em;font-weight:600;color:#0E75DD;text-align:right;padding-bottom:13px;text-decoration:underline"><a href="https://github.com/homotechsual/Blog-Scripts/blob/main/Data%20Gathering/Windows11Readiness.ps1" class="githubLink" style="margin:0 10px" target="_blank">View on GitHub</a></div></div><p><strong>Source:</strong> <a href="https://techcommunity.microsoft.com/t5/microsoft-endpoint-manager-blog/understanding-readiness-for-windows-11-with-microsoft-endpoint/ba-p/2770866" target="_blank" rel="noopener noreferrer" class="">https://techcommunity.microsoft.com/t5/microsoft-endpoint-manager-blog/understanding-readiness-for-windows-11-with-microsoft-endpoint/ba-p/2770866</a></p><p>Thanks to <a href="https://gavsto.com/" target="_blank" rel="noopener noreferrer" class="">@gavsto</a> for invaluable input on a couple of the checks in here - he's helped make them more robust and accurate.</p><p>The script's detailed output has changed and will now show two metrics related to Secure Boot. Previously it showed in <code>SecureBootSuitable</code> whether the state of Secure Boot was suitable for Windows 11 installation. This has been enhanced with a new <code>SecureBootPossible</code> metric which will show whether it's likely that Secure Boot <em>can</em> be enabled. A "No" to both metrics will indicate that Secure Boot is not enabled or not capable of being enabled and thus the device is not Windows 11 capable. A "Yes" to <code>SecureBootPossible</code> indicates that Secure Boot can likely be enabled and that this should be done to make the device Windows 11 capable.</p><h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="the-results-4">The Results<a href="https://homotechsual.dev/2022/12/22/NinjaOne-custom-fields-endless-possibilities#the-results-4" class="hash-link" aria-label="Direct link to The Results" title="Direct link to The Results" translate="no">​</a></h3><p><img decoding="async" loading="lazy" alt="Windows 11 Related Custom Fields" src="https://homotechsual.dev/assets/images/NinjaOneWindows11Fields-db1c829b37e35035f295e7096e937eea.png" width="1292" height="622" class="img_ev3q"></p><p>We ran this as a one-off job to evaluate our managed estate.</p><h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="limitations">Limitations<a href="https://homotechsual.dev/2022/12/22/NinjaOne-custom-fields-endless-possibilities#limitations" class="hash-link" aria-label="Direct link to Limitations" title="Direct link to Limitations" translate="no">​</a></h3><p>This script won't detect compatible devices if the TPM is not enabled in the BIOS. It may not detect all compatible devices. This script may not accurately detect Secure Boot capability on all devices.</p></div></div></details>
<details class="details_lb9f alert alert--info details_b_Ee" data-collapsed="true"><summary><h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="windows-os-support-status">Windows OS Support Status<a href="https://homotechsual.dev/2022/12/22/NinjaOne-custom-fields-endless-possibilities#windows-os-support-status" class="hash-link" aria-label="Direct link to Windows OS Support Status" title="Direct link to Windows OS Support Status" translate="no">​</a></h2></summary><div><div class="collapsibleContent_i85q"><h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="creating-fields-5">Creating Fields<a href="https://homotechsual.dev/2022/12/22/NinjaOne-custom-fields-endless-possibilities#creating-fields-5" class="hash-link" aria-label="Direct link to Creating Fields" title="Direct link to Creating Fields" translate="no">​</a></h3><div class="theme-admonition theme-admonition-ninja admonition_Gfwi alert alert--ninja"><div class="admonitionHeading_f1Ed"><span class="admonitionIcon_kpSf"><svg data-prefix="fas" data-icon="user-ninja" class="svg-inline--fa fa-user-ninja" role="img" viewBox="0 0 448 512" aria-hidden="true"><path fill="currentColor" d="M352 128c0 70.7-57.3 128-128 128-57.2 0-105.6-37.5-122-89.3-1.1 1.3-2.2 2.6-3.5 3.8-15.8 15.8-38.8 20.7-53.6 22.1-8.1 .8-14.6-5.7-13.8-13.8 1.4-14.7 6.3-37.8 22.1-53.6 5.8-5.8 12.6-10.1 19.6-13.4-7-3.2-13.8-7.6-19.6-13.4-15.8-15.8-20.7-38.8-22.1-53.6-.8-8.1 5.7-14.6 13.8-13.8 14.7 1.4 37.8 6.3 53.6 22.1 4.8 4.8 8.7 10.4 11.7 16.1 21.3-41.2 64.3-69.4 113.8-69.4 70.7 0 128 57.3 128 128zM144 112c0 8.8 7.2 16 16 16l128 0c8.8 0 16-7.2 16-16s-7.2-16-16-16L160 96c-8.8 0-16 7.2-16 16zm-1.4 211l67 50.2c8.5 6.4 20.3 6.4 28.8 0l67-50.2c6.5-4.9 15.2-6.2 22.6-2.8 61.4 28.2 104.1 90.2 104.1 162.1 0 16.4-13.3 29.7-29.7 29.7L45.7 512c-16.4 0-29.7-13.3-29.7-29.7 0-72 42.7-134 104.1-162.1 7.4-3.4 16.1-2.1 22.6 2.8z"></path></svg></span>Creating custom fields in NinjaOne</div><div class="admonitionContent_UjKb">To create a custom field in NinjaOne go to <b>Administration <!-- -->&gt;<!-- --> Devices</b> and select either <b>Role Custom Fields</b> or <b>Global Custom Fields</b> then select <b>Add</b>.<br><br><ul><li>Role Custom Fields are custom fields that are specific to a device role.</li><li>Global Custom Fields are custom fields that are applicable to all devices and/or to a location and/or organisation</li></ul>Make sure you add the fields to the roles you want to use them in at <b>Administration <!-- -->&gt;<!-- --> Devices <!-- -->&gt;<!-- --> Roles</b> (for role custom fields).<br><br>When you create your custom field you need to make sure that you set the <b>Scripts</b> permission to ensure that you can read or write to the field from your scripts - as appropriate for the script you're using.</div></div><p>We're adding two role custom fields for devices with the <em>Windows Desktops and Laptops</em> and the <em>Windows Server</em> role:</p><table><thead><tr><th>Field Name</th><th>Field Type</th><th>Description</th></tr></thead><tbody><tr><td>Windows Active Support</td><td>Checkbox</td><td>Whether the OS version is supported for feature / quality updates.</td></tr><tr><td>Windows Security Support</td><td>Checkbox</td><td>Whether the OS version is supported for security updates.</td></tr></tbody></table><h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="the-script-5">The Script<a href="https://homotechsual.dev/2022/12/22/NinjaOne-custom-fields-endless-possibilities#the-script-5" class="hash-link" aria-label="Direct link to The Script" title="Direct link to The Script" translate="no">​</a></h3><p>:::note "Shoutout"
Thanks to Khristos from the <a href="https://mspgeek.org/" target="_blank" rel="noopener noreferrer" class="">MSP Geek</a> community for keeping an eye on EndOfLife.Date's endlessly changing property for holding the Windows build...
:::</p><div class="theme-admonition theme-admonition-tip admonition_Gfwi alert alert--success"><div class="admonitionHeading_f1Ed"><span class="admonitionIcon_kpSf"><svg data-prefix="fas" data-icon="lightbulb" class="svg-inline--fa fa-lightbulb" role="img" viewBox="0 0 384 512" aria-hidden="true"><path fill="currentColor" d="M292.9 384c7.3-22.3 21.9-42.5 38.4-59.9 32.7-34.4 52.7-80.9 52.7-132.1 0-106-86-192-192-192S0 86 0 192c0 51.2 20 97.7 52.7 132.1 16.5 17.4 31.2 37.6 38.4 59.9l201.7 0zM288 432l-192 0 0 16c0 44.2 35.8 80 80 80l32 0c44.2 0 80-35.8 80-80l0-16zM184 112c-39.8 0-72 32.2-72 72 0 13.3-10.7 24-24 24s-24-10.7-24-24c0-66.3 53.7-120 120-120 13.3 0 24 10.7 24 24s-10.7 24-24 24z"></path></svg></span>This Script Was Updated</div><div class="admonitionContent_UjKb"><p>This script was updated after being published, if you're using it please compare the version you have with the version available here.</p><p>This script was last updated on <!-- -->2023/01/26<!-- -->.</p></div></div><div class="docusaurus-theme-github-codeblock"><div class="language-powershell codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#9CDCFE;--prism-background-color:#1E1E1E"><div class="codeBlockTitle_OeMC">Get-WindowsOSSupportStatus.ps1</div><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-powershell codeBlock_bY9V thin-scrollbar" style="color:#9CDCFE;background-color:#1E1E1E"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#9CDCFE"><span class="token plain">loading</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><br></div></code></pre></div></div><div style="font-size:.9em;font-weight:600;color:#0E75DD;text-align:right;padding-bottom:13px;text-decoration:underline"><a href="https://github.com/homotechsual/Blog-Scripts/blob/main/Monitoring/WindowsSupportStatus.ps1" class="githubLink" style="margin:0 10px" target="_blank">View on GitHub</a></div></div><h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="the-results-5">The Results<a href="https://homotechsual.dev/2022/12/22/NinjaOne-custom-fields-endless-possibilities#the-results-5" class="hash-link" aria-label="Direct link to The Results" title="Direct link to The Results" translate="no">​</a></h3><p><img decoding="async" loading="lazy" alt="Windows Support Status Related Custom Fields" src="https://homotechsual.dev/assets/images/NinjaOneOSSupportFields-76e7c17ca4d25f5164cf08f9ea8f81b8.png" width="254" height="363" class="img_ev3q"></p><p>We run this on a schedule so it runs just after our OS patching applies.</p><h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="limitations-1">Limitations<a href="https://homotechsual.dev/2022/12/22/NinjaOne-custom-fields-endless-possibilities#limitations-1" class="hash-link" aria-label="Direct link to Limitations" title="Direct link to Limitations" translate="no">​</a></h3><p>Won't work with Insider/Preview versions - hasn't been tested on Windows 7 / 8 or 8.1. Has been tested on Server 2012 R2, 2022 and Windows 10 and 11.</p></div></div></details>
<details class="details_lb9f alert alert--info details_b_Ee" data-collapsed="true"><summary><h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="speedtest-librespeed">SpeedTest (LibreSpeed)<a href="https://homotechsual.dev/2022/12/22/NinjaOne-custom-fields-endless-possibilities#speedtest-librespeed" class="hash-link" aria-label="Direct link to SpeedTest (LibreSpeed)" title="Direct link to SpeedTest (LibreSpeed)" translate="no">​</a></h2></summary><div><div class="collapsibleContent_i85q"><h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="creating-fields-6">Creating Fields<a href="https://homotechsual.dev/2022/12/22/NinjaOne-custom-fields-endless-possibilities#creating-fields-6" class="hash-link" aria-label="Direct link to Creating Fields" title="Direct link to Creating Fields" translate="no">​</a></h3><div class="theme-admonition theme-admonition-ninja admonition_Gfwi alert alert--ninja"><div class="admonitionHeading_f1Ed"><span class="admonitionIcon_kpSf"><svg data-prefix="fas" data-icon="user-ninja" class="svg-inline--fa fa-user-ninja" role="img" viewBox="0 0 448 512" aria-hidden="true"><path fill="currentColor" d="M352 128c0 70.7-57.3 128-128 128-57.2 0-105.6-37.5-122-89.3-1.1 1.3-2.2 2.6-3.5 3.8-15.8 15.8-38.8 20.7-53.6 22.1-8.1 .8-14.6-5.7-13.8-13.8 1.4-14.7 6.3-37.8 22.1-53.6 5.8-5.8 12.6-10.1 19.6-13.4-7-3.2-13.8-7.6-19.6-13.4-15.8-15.8-20.7-38.8-22.1-53.6-.8-8.1 5.7-14.6 13.8-13.8 14.7 1.4 37.8 6.3 53.6 22.1 4.8 4.8 8.7 10.4 11.7 16.1 21.3-41.2 64.3-69.4 113.8-69.4 70.7 0 128 57.3 128 128zM144 112c0 8.8 7.2 16 16 16l128 0c8.8 0 16-7.2 16-16s-7.2-16-16-16L160 96c-8.8 0-16 7.2-16 16zm-1.4 211l67 50.2c8.5 6.4 20.3 6.4 28.8 0l67-50.2c6.5-4.9 15.2-6.2 22.6-2.8 61.4 28.2 104.1 90.2 104.1 162.1 0 16.4-13.3 29.7-29.7 29.7L45.7 512c-16.4 0-29.7-13.3-29.7-29.7 0-72 42.7-134 104.1-162.1 7.4-3.4 16.1-2.1 22.6 2.8z"></path></svg></span>Creating custom fields in NinjaOne</div><div class="admonitionContent_UjKb">To create a custom field in NinjaOne go to <b>Administration <!-- -->&gt;<!-- --> Devices</b> and select either <b>Role Custom Fields</b> or <b>Global Custom Fields</b> then select <b>Add</b>.<br><br><ul><li>Role Custom Fields are custom fields that are specific to a device role.</li><li>Global Custom Fields are custom fields that are applicable to all devices and/or to a location and/or organisation</li></ul>Make sure you add the fields to the roles you want to use them in at <b>Administration <!-- -->&gt;<!-- --> Devices <!-- -->&gt;<!-- --> Roles</b> (for role custom fields).<br><br>When you create your custom field you need to make sure that you set the <b>Scripts</b> permission to ensure that you can read or write to the field from your scripts - as appropriate for the script you're using.</div></div><p>We're adding three role custom fields for devices with the <em>Windows Desktops and Laptops</em> and the <em>Windows Server</em> role:</p><table><thead><tr><th>Field Name</th><th>Field Type</th><th>Description</th></tr></thead><tbody><tr><td>Server Used</td><td>Text</td><td>Which server was used for the last speedtest run.</td></tr><tr><td>Download Speed</td><td>Decimal</td><td>The download speed from the last speedtest run in megabits per second.</td></tr><tr><td>Upload Speed</td><td>Decimal</td><td>The upload speed from the last speedtest run in megabits per second.</td></tr></tbody></table><h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="the-script-6">The Script<a href="https://homotechsual.dev/2022/12/22/NinjaOne-custom-fields-endless-possibilities#the-script-6" class="hash-link" aria-label="Direct link to The Script" title="Direct link to The Script" translate="no">​</a></h3><p>:::warning "Issues found"
This script seems to have some issues where the librespeed-cli will return <code>null</code> for tests intermittently - this was due to service issues with LibreSpeed themselves. An alternative version using the Ookla speedtest CLI is <a href="https://homotechsual.dev/2022/12/22/NinjaOne-custom-fields-endless-possibilities#speedtest-ookla-speedtest" class="">available below</a>.
:::</p><div class="theme-admonition theme-admonition-tip admonition_Gfwi alert alert--success"><div class="admonitionHeading_f1Ed"><span class="admonitionIcon_kpSf"><svg data-prefix="fas" data-icon="lightbulb" class="svg-inline--fa fa-lightbulb" role="img" viewBox="0 0 384 512" aria-hidden="true"><path fill="currentColor" d="M292.9 384c7.3-22.3 21.9-42.5 38.4-59.9 32.7-34.4 52.7-80.9 52.7-132.1 0-106-86-192-192-192S0 86 0 192c0 51.2 20 97.7 52.7 132.1 16.5 17.4 31.2 37.6 38.4 59.9l201.7 0zM288 432l-192 0 0 16c0 44.2 35.8 80 80 80l32 0c44.2 0 80-35.8 80-80l0-16zM184 112c-39.8 0-72 32.2-72 72 0 13.3-10.7 24-24 24s-24-10.7-24-24c0-66.3 53.7-120 120-120 13.3 0 24 10.7 24 24s-10.7 24-24 24z"></path></svg></span>This Script Was Updated</div><div class="admonitionContent_UjKb"><p>This script was updated after being published, if you're using it please compare the version you have with the version available here.</p><p>This script was last updated on <!-- -->2022/12/31<!-- -->.</p></div></div><div class="docusaurus-theme-github-codeblock"><div class="language-powershell codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#9CDCFE;--prism-background-color:#1E1E1E"><div class="codeBlockTitle_OeMC">Test-ConnectionSpeedwithLibreSpeed.ps1</div><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-powershell codeBlock_bY9V thin-scrollbar" style="color:#9CDCFE;background-color:#1E1E1E"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#9CDCFE"><span class="token plain">loading</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><br></div></code></pre></div></div><div style="font-size:.9em;font-weight:600;color:#0E75DD;text-align:right;padding-bottom:13px;text-decoration:underline"><a href="https://github.com/homotechsual/Blog-Scripts/blob/main/Monitoring/Speed%20Test/LibreSpeed.ps1" class="githubLink" style="margin:0 10px" target="_blank">View on GitHub</a></div></div><h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="parameters">Parameters<a href="https://homotechsual.dev/2022/12/22/NinjaOne-custom-fields-endless-possibilities#parameters" class="hash-link" aria-label="Direct link to Parameters" title="Direct link to Parameters" translate="no">​</a></h3><p>You can pass a few different parameters to this script to tune it's behaviour. These are:</p><table><thead><tr><th>Parameter Name</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td>LibreSpeedEXEPath</td><td>String</td><td>The path to the LibreSpeed executable. Defaults to C:\RMM\Bin\</td></tr><tr><td>NoUpdate</td><td>Switch</td><td>If specified, the script will not attempt to update or download LibreSpeed.</td></tr><tr><td>ForceUpdate</td><td>Switch</td><td>If specified, the script will download LibreSpeed even if it's already up to date.</td></tr><tr><td>CLISwitches</td><td>String</td><td>A string of switches to pass to the LibreSpeed CLI. Defaults to <code>--json</code>.</td></tr></tbody></table><p>For documentation on the CLI switches available see the <a href="https://github.com/librespeed/speedtest-cli#usage" target="_blank" rel="noopener noreferrer" class="">LibreSpeed CLI documentation</a>.</p><h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="the-results-6">The Results<a href="https://homotechsual.dev/2022/12/22/NinjaOne-custom-fields-endless-possibilities#the-results-6" class="hash-link" aria-label="Direct link to The Results" title="Direct link to The Results" translate="no">​</a></h3><p><img decoding="async" loading="lazy" alt="Speed Test Related Custom Fields" src="https://homotechsual.dev/assets/images/NinjaOneSpeedTestFields-ddd7f8b923b177863aa34d7e44a0a96d.png" width="216" height="214" class="img_ev3q"></p><p>In this screenshot we've added a separator and a nice custom title with an emoji to make it look a bit nicer.</p><blockquote>
<p>⏱️SPEEDTEST</p>
</blockquote><p>We run this on demand when we want to refresh information on the device - we don't run it on a schedule at present.</p><h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="limitations-2">Limitations<a href="https://homotechsual.dev/2022/12/22/NinjaOne-custom-fields-endless-possibilities#limitations-2" class="hash-link" aria-label="Direct link to Limitations" title="Direct link to Limitations" translate="no">​</a></h3><p>Requires the ability to run the LibreSpeed CLI tool on the device. The script can fetch the latest version and will do so automatically.</p></div></div></details>
<details class="details_lb9f alert alert--info details_b_Ee" data-collapsed="true"><summary><h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="speedtest-ookla-speedtest">SpeedTest (Ookla Speedtest)<a href="https://homotechsual.dev/2022/12/22/NinjaOne-custom-fields-endless-possibilities#speedtest-ookla-speedtest" class="hash-link" aria-label="Direct link to SpeedTest (Ookla Speedtest)" title="Direct link to SpeedTest (Ookla Speedtest)" translate="no">​</a></h2></summary><div><div class="collapsibleContent_i85q"><h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="creating-fields-7">Creating Fields<a href="https://homotechsual.dev/2022/12/22/NinjaOne-custom-fields-endless-possibilities#creating-fields-7" class="hash-link" aria-label="Direct link to Creating Fields" title="Direct link to Creating Fields" translate="no">​</a></h3><div class="theme-admonition theme-admonition-ninja admonition_Gfwi alert alert--ninja"><div class="admonitionHeading_f1Ed"><span class="admonitionIcon_kpSf"><svg data-prefix="fas" data-icon="user-ninja" class="svg-inline--fa fa-user-ninja" role="img" viewBox="0 0 448 512" aria-hidden="true"><path fill="currentColor" d="M352 128c0 70.7-57.3 128-128 128-57.2 0-105.6-37.5-122-89.3-1.1 1.3-2.2 2.6-3.5 3.8-15.8 15.8-38.8 20.7-53.6 22.1-8.1 .8-14.6-5.7-13.8-13.8 1.4-14.7 6.3-37.8 22.1-53.6 5.8-5.8 12.6-10.1 19.6-13.4-7-3.2-13.8-7.6-19.6-13.4-15.8-15.8-20.7-38.8-22.1-53.6-.8-8.1 5.7-14.6 13.8-13.8 14.7 1.4 37.8 6.3 53.6 22.1 4.8 4.8 8.7 10.4 11.7 16.1 21.3-41.2 64.3-69.4 113.8-69.4 70.7 0 128 57.3 128 128zM144 112c0 8.8 7.2 16 16 16l128 0c8.8 0 16-7.2 16-16s-7.2-16-16-16L160 96c-8.8 0-16 7.2-16 16zm-1.4 211l67 50.2c8.5 6.4 20.3 6.4 28.8 0l67-50.2c6.5-4.9 15.2-6.2 22.6-2.8 61.4 28.2 104.1 90.2 104.1 162.1 0 16.4-13.3 29.7-29.7 29.7L45.7 512c-16.4 0-29.7-13.3-29.7-29.7 0-72 42.7-134 104.1-162.1 7.4-3.4 16.1-2.1 22.6 2.8z"></path></svg></span>Creating custom fields in NinjaOne</div><div class="admonitionContent_UjKb">To create a custom field in NinjaOne go to <b>Administration <!-- -->&gt;<!-- --> Devices</b> and select either <b>Role Custom Fields</b> or <b>Global Custom Fields</b> then select <b>Add</b>.<br><br><ul><li>Role Custom Fields are custom fields that are specific to a device role.</li><li>Global Custom Fields are custom fields that are applicable to all devices and/or to a location and/or organisation</li></ul>Make sure you add the fields to the roles you want to use them in at <b>Administration <!-- -->&gt;<!-- --> Devices <!-- -->&gt;<!-- --> Roles</b> (for role custom fields).<br><br>When you create your custom field you need to make sure that you set the <b>Scripts</b> permission to ensure that you can read or write to the field from your scripts - as appropriate for the script you're using.</div></div><p>We're adding three role custom fields for devices with the <em>Windows Desktops and Laptops</em> and the <em>Windows Server</em> role:</p><table><thead><tr><th>Field Name</th><th>Field Type</th><th>Description</th></tr></thead><tbody><tr><td>Server Used</td><td>Text</td><td>Which server was used for the last speedtest run.</td></tr><tr><td>Download Speed</td><td>Decimal</td><td>The download speed from the last speedtest run in megabits per second.</td></tr><tr><td>Upload Speed</td><td>Decimal</td><td>The upload speed from the last speedtest run in megabits per second.</td></tr></tbody></table><h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="the-script-7">The Script<a href="https://homotechsual.dev/2022/12/22/NinjaOne-custom-fields-endless-possibilities#the-script-7" class="hash-link" aria-label="Direct link to The Script" title="Direct link to The Script" translate="no">​</a></h3><div class="docusaurus-theme-github-codeblock"><div class="language-powershell codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#9CDCFE;--prism-background-color:#1E1E1E"><div class="codeBlockTitle_OeMC">Test-ConnectionSpeedwithOoklaSpeedtest.ps1</div><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-powershell codeBlock_bY9V thin-scrollbar" style="color:#9CDCFE;background-color:#1E1E1E"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#9CDCFE"><span class="token plain">loading</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><br></div></code></pre></div></div><div style="font-size:.9em;font-weight:600;color:#0E75DD;text-align:right;padding-bottom:13px;text-decoration:underline"><a href="https://github.com/homotechsual/Blog-Scripts/blob/main/Monitoring/Speed%20Test/OoklaSpeedtest.ps1" class="githubLink" style="margin:0 10px" target="_blank">View on GitHub</a></div></div><h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="parameters-1">Parameters<a href="https://homotechsual.dev/2022/12/22/NinjaOne-custom-fields-endless-possibilities#parameters-1" class="hash-link" aria-label="Direct link to Parameters" title="Direct link to Parameters" translate="no">​</a></h3><p>You can pass a few different parameters to this script to tune it's behaviour. These are:</p><table><thead><tr><th>Parameter Name</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td>OoklaSpeedtestURI</td><td>String</td><td>The URI to the Ookla Speedtest CLI. Defaults to the 1.2.0 version current when written.</td></tr><tr><td>OoklaSpeedtestEXEPath</td><td>String</td><td>The path to the Ookla Speedtest executable. Defaults to C:\RMM\Bin\</td></tr><tr><td>NoUpdate</td><td>Switch</td><td>If specified, the script will not attempt to update or download Ookla Speedtest.</td></tr><tr><td>ForceUpdate</td><td>Switch</td><td>If specified, the script will download Ookla Speedtest even if it's already up to date.</td></tr><tr><td>CLISwitches</td><td>String</td><td>A string of switches to pass to the Ookla Speedtest CLI. Defaults to <code>--format=json --accept-license --accept-gdpr</code>.</td></tr></tbody></table><p>For documentation on the CLI switches available you should download the latest version of the CLI and check out the speedtest.md file in the Zip or run <code>speedtest.exe --help</code>.</p><h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="the-results-7">The Results<a href="https://homotechsual.dev/2022/12/22/NinjaOne-custom-fields-endless-possibilities#the-results-7" class="hash-link" aria-label="Direct link to The Results" title="Direct link to The Results" translate="no">​</a></h3><p><img decoding="async" loading="lazy" alt="Speed Test Related Custom Fields" src="https://homotechsual.dev/assets/images/NinjaOneSpeedTestFields-ddd7f8b923b177863aa34d7e44a0a96d.png" width="216" height="214" class="img_ev3q"></p><p>In this screenshot we've added a separator and a nice custom title with an emoji to make it look a bit nicer.</p><blockquote>
<p>⏱️SPEEDTEST</p>
</blockquote><p>We run this on demand when we want to refresh information on the device - we don't run it on a schedule at present.</p><h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="limitations-3">Limitations<a href="https://homotechsual.dev/2022/12/22/NinjaOne-custom-fields-endless-possibilities#limitations-3" class="hash-link" aria-label="Direct link to Limitations" title="Direct link to Limitations" translate="no">​</a></h3><p>Requires the ability to run the Ookla Speedtest CLI tool on the device. The script cannot automatically determine the latest version at this time - please pass an updated URL if you wish to use a later version before the script is updated.</p></div></div></details>]]></content:encoded>
            <category>NinjaOne</category>
            <category>Custom Fields</category>
            <category>PowerShell</category>
        </item>
        <item>
            <title><![CDATA[Monitoring AntiVirus status with PowerShell]]></title>
            <link>https://homotechsual.dev/2022/10/05/Monitoring-AV-PowerShell</link>
            <guid>https://homotechsual.dev/2022/10/05/Monitoring-AV-PowerShell</guid>
            <pubDate>Wed, 05 Oct 2022 00:00:00 GMT</pubDate>
            <description><![CDATA[Background information]]></description>
            <content:encoded><![CDATA[<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="background-information">Background information<a href="https://homotechsual.dev/2022/10/05/Monitoring-AV-PowerShell#background-information" class="hash-link" aria-label="Direct link to Background information" title="Direct link to Background information" translate="no">​</a></h2>
<p>Ninja doesn't currently support native AV monitoring via Windows Security Center, integrated AV packages are monitored but what if you need more?</p>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="creating-fields">Creating Fields<a href="https://homotechsual.dev/2022/10/05/Monitoring-AV-PowerShell#creating-fields" class="hash-link" aria-label="Direct link to Creating Fields" title="Direct link to Creating Fields" translate="no">​</a></h2>
<div class="theme-admonition theme-admonition-ninja admonition_Gfwi alert alert--ninja"><div class="admonitionHeading_f1Ed"><span class="admonitionIcon_kpSf"><svg data-prefix="fas" data-icon="user-ninja" class="svg-inline--fa fa-user-ninja" role="img" viewBox="0 0 448 512" aria-hidden="true"><path fill="currentColor" d="M352 128c0 70.7-57.3 128-128 128-57.2 0-105.6-37.5-122-89.3-1.1 1.3-2.2 2.6-3.5 3.8-15.8 15.8-38.8 20.7-53.6 22.1-8.1 .8-14.6-5.7-13.8-13.8 1.4-14.7 6.3-37.8 22.1-53.6 5.8-5.8 12.6-10.1 19.6-13.4-7-3.2-13.8-7.6-19.6-13.4-15.8-15.8-20.7-38.8-22.1-53.6-.8-8.1 5.7-14.6 13.8-13.8 14.7 1.4 37.8 6.3 53.6 22.1 4.8 4.8 8.7 10.4 11.7 16.1 21.3-41.2 64.3-69.4 113.8-69.4 70.7 0 128 57.3 128 128zM144 112c0 8.8 7.2 16 16 16l128 0c8.8 0 16-7.2 16-16s-7.2-16-16-16L160 96c-8.8 0-16 7.2-16 16zm-1.4 211l67 50.2c8.5 6.4 20.3 6.4 28.8 0l67-50.2c6.5-4.9 15.2-6.2 22.6-2.8 61.4 28.2 104.1 90.2 104.1 162.1 0 16.4-13.3 29.7-29.7 29.7L45.7 512c-16.4 0-29.7-13.3-29.7-29.7 0-72 42.7-134 104.1-162.1 7.4-3.4 16.1-2.1 22.6 2.8z"></path></svg></span>Creating custom fields in NinjaOne</div><div class="admonitionContent_UjKb">To create a custom field in NinjaOne go to <b>Administration <!-- -->&gt;<!-- --> Devices</b> and select either <b>Role Custom Fields</b> or <b>Global Custom Fields</b> then select <b>Add</b>.<br><br><ul><li>Role Custom Fields are custom fields that are specific to a device role.</li><li>Global Custom Fields are custom fields that are applicable to all devices and/or to a location and/or organisation</li></ul>Make sure you add the fields to the roles you want to use them in at <b>Administration <!-- -->&gt;<!-- --> Devices <!-- -->&gt;<!-- --> Roles</b> (for role custom fields).<br><br>When you create your custom field you need to make sure that you set the <b>Scripts</b> permission to ensure that you can read or write to the field from your scripts - as appropriate for the script you're using.</div></div>
<p>We're going to create one role custom field for devices with the <em>Windows Desktop or Windows Laptop</em> role:</p>
<table><thead><tr><th>Field Name</th><th>Field Type</th><th>Description</th></tr></thead><tbody><tr><td>Detailed AV Status</td><td>Multi-Line</td><td>Output for each configured AV on the system including name and status information.</td></tr></tbody></table>
<!-- -->
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="the-script">The Script<a href="https://homotechsual.dev/2022/10/05/Monitoring-AV-PowerShell#the-script" class="hash-link" aria-label="Direct link to The Script" title="Direct link to The Script" translate="no">​</a></h2>
<p>:::caution Windows Server
This script won't work on Windows Server operating systems as they lack a CIM or WMI interface to the Windows Security Center which allows us to easily programmatically query the AV status.
:::</p>
<div class="docusaurus-theme-github-codeblock"><div class="language-powershell codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#9CDCFE;--prism-background-color:#1E1E1E"><div class="codeBlockTitle_OeMC">Get-WindowsAVStatus.ps1</div><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-powershell codeBlock_bY9V thin-scrollbar" style="color:#9CDCFE;background-color:#1E1E1E"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#9CDCFE"><span class="token plain">loading</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><br></div></code></pre></div></div><div style="font-size:.9em;font-weight:600;color:#0E75DD;text-align:right;padding-bottom:13px;text-decoration:underline"><a href="https://github.com/homotechsual/Blog-Scripts/blob/main/Monitoring/WindowsAVStatus.ps1" class="githubLink" style="margin:0 10px" target="_blank">View on GitHub</a></div></div>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="monitoring">Monitoring<a href="https://homotechsual.dev/2022/10/05/Monitoring-AV-PowerShell#monitoring" class="hash-link" aria-label="Direct link to Monitoring" title="Direct link to Monitoring" translate="no">​</a></h2>
<p>The script includes support for two monitors.</p>
<h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="av-not-enabled">AV Not Enabled<a href="https://homotechsual.dev/2022/10/05/Monitoring-AV-PowerShell#av-not-enabled" class="hash-link" aria-label="Direct link to AV Not Enabled" title="Direct link to AV Not Enabled" translate="no">​</a></h3>
<p>Setup a script result condition monitor that runs this script with a check for an exit code of 1.</p>
<p><img decoding="async" loading="lazy" alt="AV Not Enabled Condition" src="https://homotechsual.dev/assets/images/AVNotEnabledCondition-b34ab8c13c40667b08a7f8da4f6fb0ac.png" width="904" height="754" class="img_ev3q"></p>
<p><img decoding="async" loading="lazy" alt="AV Not Enabled Monitor" src="https://homotechsual.dev/assets/images/AVNotEnabledMonitor-6466ed94896c30d72841127cbefc3adc.png" width="705" height="662" class="img_ev3q"></p>
<h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="av-not-up-to-date">AV Not Up-To-Date<a href="https://homotechsual.dev/2022/10/05/Monitoring-AV-PowerShell#av-not-up-to-date" class="hash-link" aria-label="Direct link to AV Not Up-To-Date" title="Direct link to AV Not Up-To-Date" translate="no">​</a></h3>
<p>Setup a second script result condition monitor that runs this script with a check for an exit code of 2.</p>
<p><img decoding="async" loading="lazy" alt="AV Not Enabled Condition" src="https://homotechsual.dev/assets/images/AVNotUpToDateCondition-bb8f9b5aefb856089c443e84168e2a83.png" width="902" height="753" class="img_ev3q"></p>
<p><img decoding="async" loading="lazy" alt="AV Not Enabled Monitor" src="https://homotechsual.dev/assets/images/AVNotUpToDateMonitor-e0f566cc66eb32f6afa45362675ffcf9.png" width="704" height="663" class="img_ev3q"></p>]]></content:encoded>
            <category>PowerShell</category>
            <category>Security</category>
            <category>AntiVirus</category>
            <category>Security Center</category>
            <category>Scripting</category>
            <category>NinjaOne</category>
            <category>RMM</category>
        </item>
        <item>
            <title><![CDATA[Exchange Online Automation with PowerShell for Microsoft Partners]]></title>
            <link>https://homotechsual.dev/2022/09/07/Connecting-Exchange-Online-Delegated-REST</link>
            <guid>https://homotechsual.dev/2022/09/07/Connecting-Exchange-Online-Delegated-REST</guid>
            <pubDate>Wed, 07 Sep 2022 00:00:00 GMT</pubDate>
            <description><![CDATA[<CodeSource]]></description>
            <content:encoded><![CDATA[<section class="row"><div class="col col--6"><span class="hero__wrapper"><section class="post__hero hero shadow--md bordered bordered"><div class="container"><h2 class="hero__title"><strong>Secure Application Model</strong></h2><p class="hero__subtitle">For this post you'll want a secure application model Azure AD application configured. Use these instructions from Gavin Stone's Gavsto.com blog.</p><div class="hero__button"><a class="button button--primary button--outline button--lg" href="https://www.gavsto.com/secure-application-model-for-the-layman-and-step-by-step/">Read Instructions</a></div></div></section></span></div><div class="col col--6"><span class="hero__wrapper"><section class="post__hero hero shadow--md bordered bordered"><div class="container"><h2 class="hero__title"><strong>CIPP Inspired</strong></h2><p class="hero__subtitle">The code in this script was inspired by functionality in the CyberDrain Improved Partner Portal (CIPP). Need to manage M365 tenants - CIPP is a fantastic open-source solution for M365 management for single tenants and Microsoft CSP Partners alike.</p><div class="hero__button"><a class="button button--primary button--outline button--lg" href="https://cipp.app/">Check Out CIPP</a></div></div></section></span></div></section>
<!-- -->
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="background-information">Background information<a href="https://homotechsual.dev/2022/09/07/Connecting-Exchange-Online-Delegated-REST#background-information" class="hash-link" aria-label="Direct link to Background information" title="Direct link to Background information" translate="no">​</a></h2>
<p>In my quest to stop having to use Windows Sandbox or VMs to access Exchange Online via PowerShell (we have WinRM basic auth disabled) I've been looking at solutions using the Exchange Online REST API to run commands against our customer tenants. The result of my efforts is a pretty complex script that introduces a method to run any PowerShell script in the context of a set of customer tenants.</p>
<div class="theme-admonition theme-admonition-caution admonition_Gfwi alert alert--warning"><div class="admonitionHeading_f1Ed"><span class="admonitionIcon_kpSf"><svg data-prefix="fas" data-icon="triangle-exclamation" class="svg-inline--fa fa-triangle-exclamation" role="img" viewBox="0 0 512 512" aria-hidden="true"><path fill="currentColor" d="M256 0c14.7 0 28.2 8.1 35.2 21l216 400c6.7 12.4 6.4 27.4-.8 39.5S486.1 480 472 480L40 480c-14.1 0-27.2-7.4-34.4-19.5s-7.5-27.1-.8-39.5l216-400c7-12.9 20.5-21 35.2-21zm0 352a32 32 0 1 0 0 64 32 32 0 1 0 0-64zm0-192c-18.2 0-32.7 15.5-31.4 33.7l7.4 104c.9 12.5 11.4 22.3 23.9 22.3 12.6 0 23-9.7 23.9-22.3l7.4-104c1.3-18.2-13.1-33.7-31.4-33.7z"></path></svg></span>caution</div><div class="admonitionContent_UjKb"><p>You need to have configured the Secure Application Model according to the instructions linked above, you will need your SAM tokens etc accessible for this guide.</p></div></div>
<div class="theme-admonition theme-admonition-security admonition_Gfwi alert alert--security"><div class="admonitionHeading_f1Ed"><span class="admonitionIcon_kpSf"><svg data-prefix="fas" data-icon="shield-halved" class="svg-inline--fa fa-shield-halved" role="img" viewBox="0 0 512 512" aria-hidden="true"><path fill="currentColor" d="M256 0c4.6 0 9.2 1 13.4 2.9L457.8 82.8c22 9.3 38.4 31 38.3 57.2-.5 99.2-41.3 280.7-213.6 363.2-16.7 8-36.1 8-52.8 0-172.4-82.5-213.1-264-213.6-363.2-.1-26.2 16.3-47.9 38.3-57.2L242.7 2.9C246.9 1 251.4 0 256 0zm0 66.8l0 378.1c138-66.8 175.1-214.8 176-303.4l-176-74.6 0 0z"></path></svg></span>Securing Credentials in Scripts</div><div class="admonitionContent_UjKb">Do not store credentials directly in scripts. You should utilise services like Azure KeyVault or other PAM solutions to secure credentials used in scripts, including this one.</div></div>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="the-script">The script<a href="https://homotechsual.dev/2022/09/07/Connecting-Exchange-Online-Delegated-REST#the-script" class="hash-link" aria-label="Direct link to The script" title="Direct link to The script" translate="no">​</a></h2>
<div class="docusaurus-theme-github-codeblock"><div class="language-powershell codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#9CDCFE;--prism-background-color:#1E1E1E"><div class="codeBlockTitle_OeMC">Invoke-EORESTDelegated.ps1</div><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-powershell codeBlock_bY9V thin-scrollbar" style="color:#9CDCFE;background-color:#1E1E1E"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#9CDCFE"><span class="token plain">loading</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><br></div></code></pre></div></div><div style="font-size:.9em;font-weight:600;color:#0E75DD;text-align:right;padding-bottom:13px;text-decoration:underline"><a href="https://github.com/homotechsual/Blog-Scripts/blob/main/Microsoft%20365/Exchange%20Online/EORest.ps1" class="githubLink" style="margin:0 10px" target="_blank">View on GitHub</a></div></div>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="building-parameters">Building Parameters<a href="https://homotechsual.dev/2022/09/07/Connecting-Exchange-Online-Delegated-REST#building-parameters" class="hash-link" aria-label="Direct link to Building Parameters" title="Direct link to Building Parameters" translate="no">​</a></h2>
<p>Personally I find passing parameters as a HashTable (<a href="https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_splatting?view=powershell-7.2" target="_blank" rel="noopener noreferrer" class="">splatting</a>) easier to read and cleaner see what's happening so that's what I'm doing to explain the parameters for the script:</p>
<div class="language-powershell codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#9CDCFE;--prism-background-color:#1E1E1E"><div class="codeBlockTitle_OeMC">Parameter Splat</div><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-powershell codeBlock_bY9V thin-scrollbar" style="color:#9CDCFE;background-color:#1E1E1E"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#9CDCFE"><span class="token variable" style="color:rgb(156, 220, 254)">$EORESTParameters</span><span class="token plain"> = @</span><span class="token punctuation" style="color:rgb(212, 212, 212)">{</span><span class="token plain"></span><br></div><div class="token-line" style="color:#9CDCFE"><span class="token plain">  PartnerTenantId = </span><span class="token punctuation" style="color:rgb(212, 212, 212)">(</span><span class="token function" style="color:rgb(220, 220, 170)">Get-AzKeyVaultSecret</span><span class="token plain"> </span><span class="token operator" style="color:rgb(212, 212, 212)">-</span><span class="token plain">VaultName </span><span class="token string" style="color:rgb(206, 145, 120)">'Homotechsual'</span><span class="token plain"> </span><span class="token operator" style="color:rgb(212, 212, 212)">-</span><span class="token plain">Name </span><span class="token string" style="color:rgb(206, 145, 120)">'EORESTTenantId'</span><span class="token plain"> </span><span class="token operator" style="color:rgb(212, 212, 212)">-</span><span class="token plain">AsPlainText</span><span class="token punctuation" style="color:rgb(212, 212, 212)">)</span><span class="token plain"> </span><span class="token comment" style="color:rgb(106, 153, 85)"># Your partner tenant id.</span><span class="token plain"></span><br></div><div class="token-line" style="color:#9CDCFE"><span class="token plain">  ApplicationId = </span><span class="token punctuation" style="color:rgb(212, 212, 212)">(</span><span class="token function" style="color:rgb(220, 220, 170)">Get-AzKeyVaultSecret</span><span class="token plain"> </span><span class="token operator" style="color:rgb(212, 212, 212)">-</span><span class="token plain">VaultName </span><span class="token string" style="color:rgb(206, 145, 120)">'Homotechsual'</span><span class="token plain"> </span><span class="token operator" style="color:rgb(212, 212, 212)">-</span><span class="token plain">Name </span><span class="token string" style="color:rgb(206, 145, 120)">'EORESTClientId'</span><span class="token plain"> </span><span class="token operator" style="color:rgb(212, 212, 212)">-</span><span class="token plain">AsPlainText</span><span class="token punctuation" style="color:rgb(212, 212, 212)">)</span><span class="token plain"> </span><span class="token comment" style="color:rgb(106, 153, 85)"># Your SAM application / client id.</span><span class="token plain"></span><br></div><div class="token-line" style="color:#9CDCFE"><span class="token plain">  ApplicationSecret = </span><span class="token punctuation" style="color:rgb(212, 212, 212)">(</span><span class="token function" style="color:rgb(220, 220, 170)">Get-AzKeyVaultSecret</span><span class="token plain"> </span><span class="token operator" style="color:rgb(212, 212, 212)">-</span><span class="token plain">VaultName </span><span class="token string" style="color:rgb(206, 145, 120)">'Homotechsual'</span><span class="token plain"> </span><span class="token operator" style="color:rgb(212, 212, 212)">-</span><span class="token plain">Name </span><span class="token string" style="color:rgb(206, 145, 120)">'EORESTClientSecret'</span><span class="token plain"> </span><span class="token operator" style="color:rgb(212, 212, 212)">-</span><span class="token plain">AsPlainText</span><span class="token punctuation" style="color:rgb(212, 212, 212)">)</span><span class="token plain"> </span><span class="token comment" style="color:rgb(106, 153, 85)"># Your SAM application / client secret.</span><span class="token plain"></span><br></div><div class="token-line" style="color:#9CDCFE"><span class="token plain">  GraphRefreshToken = </span><span class="token punctuation" style="color:rgb(212, 212, 212)">(</span><span class="token function" style="color:rgb(220, 220, 170)">Get-AzKeyVaultSecret</span><span class="token plain"> </span><span class="token operator" style="color:rgb(212, 212, 212)">-</span><span class="token plain">VaultName </span><span class="token string" style="color:rgb(206, 145, 120)">'Homotechsual'</span><span class="token plain"> </span><span class="token operator" style="color:rgb(212, 212, 212)">-</span><span class="token plain">Name </span><span class="token string" style="color:rgb(206, 145, 120)">'EORESTRefreshToken'</span><span class="token plain"> </span><span class="token operator" style="color:rgb(212, 212, 212)">-</span><span class="token plain">AsPlainText</span><span class="token punctuation" style="color:rgb(212, 212, 212)">)</span><span class="token plain"> </span><span class="token comment" style="color:rgb(106, 153, 85)"># The Graph refresh t oken provided by the SAM app creation script.</span><span class="token plain"></span><br></div><div class="token-line" style="color:#9CDCFE"><span class="token plain">  ExchangeRefreshToken = </span><span class="token punctuation" style="color:rgb(212, 212, 212)">(</span><span class="token function" style="color:rgb(220, 220, 170)">Get-AzKeyVaultSecret</span><span class="token plain"> </span><span class="token operator" style="color:rgb(212, 212, 212)">-</span><span class="token plain">VaultName </span><span class="token string" style="color:rgb(206, 145, 120)">'Homotechsual'</span><span class="token plain"> </span><span class="token operator" style="color:rgb(212, 212, 212)">-</span><span class="token plain">Name </span><span class="token string" style="color:rgb(206, 145, 120)">'EORESTExchangeRefreshToken'</span><span class="token plain"> </span><span class="token operator" style="color:rgb(212, 212, 212)">-</span><span class="token plain">AsPlainText</span><span class="token punctuation" style="color:rgb(212, 212, 212)">)</span><span class="token plain"> </span><span class="token comment" style="color:rgb(106, 153, 85)"># The Exchange refresh token provided by the SAM app creation script.</span><span class="token plain"></span><br></div><div class="token-line" style="color:#9CDCFE"><span class="token plain">  UPN = </span><span class="token string" style="color:rgb(206, 145, 120)">'mikey@homotechsual.dev'</span><span class="token plain"> </span><span class="token comment" style="color:rgb(106, 153, 85)"># The UPN of the user used to authorise your SAM tokens.</span><span class="token plain"></span><br></div><div class="token-line" style="color:#9CDCFE"><span class="token plain">  IncludeTenants = @</span><span class="token punctuation" style="color:rgb(212, 212, 212)">(</span><span class="token string" style="color:rgb(206, 145, 120)">'test1.onmicrosoft.com'</span><span class="token punctuation" style="color:rgb(212, 212, 212)">)</span><span class="token plain"> </span><span class="token comment" style="color:rgb(106, 153, 85)"># Run only on the tenants listed - using the tenant's `DefaultDomainName`. This input is NOT validated.</span><span class="token plain"></span><br></div><div class="token-line" style="color:#9CDCFE"><span class="token plain">  ExcludeTenants = @</span><span class="token punctuation" style="color:rgb(212, 212, 212)">(</span><span class="token string" style="color:rgb(206, 145, 120)">'test1.onmicrosoft.com'</span><span class="token punctuation" style="color:rgb(212, 212, 212)">)</span><span class="token plain"> </span><span class="token comment" style="color:rgb(106, 153, 85)"># Run on the all tenant except those listed - using the tenant's `DefaultDomainName`.</span><span class="token plain"></span><br></div><div class="token-line" style="color:#9CDCFE"><span class="token plain"></span><span class="token punctuation" style="color:rgb(212, 212, 212)">}</span><br></div></code></pre></div></div>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="scriptblock">ScriptBlock<a href="https://homotechsual.dev/2022/09/07/Connecting-Exchange-Online-Delegated-REST#scriptblock" class="hash-link" aria-label="Direct link to ScriptBlock" title="Direct link to ScriptBlock" translate="no">​</a></h2>
<p>The <code>-ScriptBlock</code> parameter passed to the script runs the commands given against each selected tenant's Exchange Online. You should use the <code>Invoke-EORequest</code> cmdlet in the script block to send commands to ExchangeOnline. For example to get mailboxes:</p>
<div class="language-powershell codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#9CDCFE;--prism-background-color:#1E1E1E"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-powershell codeBlock_bY9V thin-scrollbar" style="color:#9CDCFE;background-color:#1E1E1E"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#9CDCFE"><span class="token operator" style="color:rgb(212, 212, 212)">-</span><span class="token plain">ScriptBlock </span><span class="token punctuation" style="color:rgb(212, 212, 212)">{</span><span class="token plain"> </span><span class="token function" style="color:rgb(220, 220, 170)">Invoke-EORequest</span><span class="token plain"> </span><span class="token operator" style="color:rgb(212, 212, 212)">-</span><span class="token plain">Commandlet </span><span class="token string" style="color:rgb(206, 145, 120)">'Get-Mailbox'</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(212, 212, 212)">}</span><br></div></code></pre></div></div>
<p>More examples are given below.</p>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="result-structure">Result structure<a href="https://homotechsual.dev/2022/09/07/Connecting-Exchange-Online-Delegated-REST#result-structure" class="hash-link" aria-label="Direct link to Result structure" title="Direct link to Result structure" translate="no">​</a></h2>
<p>Before returning values we add a property to object containing the customer's tenant id. This property is called <code>EORCustomerId</code> and is the tenant GUID. You can use this to group results by the tenant they relate to.</p>
<div class="language-powershell codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#9CDCFE;--prism-background-color:#1E1E1E"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-powershell codeBlock_bY9V thin-scrollbar" style="color:#9CDCFE;background-color:#1E1E1E"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#9CDCFE"><span class="token punctuation" style="color:rgb(212, 212, 212)">|</span><span class="token plain"> </span><span class="token function" style="color:rgb(220, 220, 170)">Group-Object</span><span class="token plain"> </span><span class="token operator" style="color:rgb(212, 212, 212)">-</span><span class="token plain">Property </span><span class="token string" style="color:rgb(206, 145, 120)">'EORCustomerId'</span><br></div></code></pre></div></div>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="example-uses">Example uses<a href="https://homotechsual.dev/2022/09/07/Connecting-Exchange-Online-Delegated-REST#example-uses" class="hash-link" aria-label="Direct link to Example uses" title="Direct link to Example uses" translate="no">​</a></h2>
<p>These examples assume use of the parameter splat above</p>
<h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="get-mailbox-plans">Get Mailbox Plans<a href="https://homotechsual.dev/2022/09/07/Connecting-Exchange-Online-Delegated-REST#get-mailbox-plans" class="hash-link" aria-label="Direct link to Get Mailbox Plans" title="Direct link to Get Mailbox Plans" translate="no">​</a></h3>
<div class="language-powershell codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#9CDCFE;--prism-background-color:#1E1E1E"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-powershell codeBlock_bY9V thin-scrollbar" style="color:#9CDCFE;background-color:#1E1E1E"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#9CDCFE"><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><span class="token plain">\</span><span class="token function" style="color:rgb(220, 220, 170)">Invoke-EORESTDelegated</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><span class="token plain">ps1 @EORESTParameters </span><span class="token operator" style="color:rgb(212, 212, 212)">-</span><span class="token plain">ScriptBlock </span><span class="token punctuation" style="color:rgb(212, 212, 212)">{</span><span class="token plain"> </span><span class="token function" style="color:rgb(220, 220, 170)">Invoke-EORequest</span><span class="token plain"> </span><span class="token operator" style="color:rgb(212, 212, 212)">-</span><span class="token plain">Commandlet </span><span class="token string" style="color:rgb(206, 145, 120)">'Get-MailboxPlan'</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(212, 212, 212)">}</span><br></div></code></pre></div></div>
<h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="get-shared-room-equipment-group-and-team-mailboxes">Get Shared, Room, Equipment, Group and Team mailboxes<a href="https://homotechsual.dev/2022/09/07/Connecting-Exchange-Online-Delegated-REST#get-shared-room-equipment-group-and-team-mailboxes" class="hash-link" aria-label="Direct link to Get Shared, Room, Equipment, Group and Team mailboxes" title="Direct link to Get Shared, Room, Equipment, Group and Team mailboxes" translate="no">​</a></h3>
<div class="language-powershell codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#9CDCFE;--prism-background-color:#1E1E1E"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-powershell codeBlock_bY9V thin-scrollbar" style="color:#9CDCFE;background-color:#1E1E1E"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#9CDCFE"><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><span class="token plain">\</span><span class="token function" style="color:rgb(220, 220, 170)">Invoke-EORESTDelegated</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><span class="token plain">ps1 @EORESTParameters </span><span class="token operator" style="color:rgb(212, 212, 212)">-</span><span class="token plain">ScriptBlock </span><span class="token punctuation" style="color:rgb(212, 212, 212)">{</span><span class="token plain"> </span><span class="token function" style="color:rgb(220, 220, 170)">Invoke-EORequest</span><span class="token plain"> </span><span class="token operator" style="color:rgb(212, 212, 212)">-</span><span class="token plain">Commandlet </span><span class="token string" style="color:rgb(206, 145, 120)">'Get-Mailbox'</span><span class="token plain"> </span><span class="token operator" style="color:rgb(212, 212, 212)">-</span><span class="token plain">Parameters @</span><span class="token punctuation" style="color:rgb(212, 212, 212)">{</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(86, 156, 214)">Filter</span><span class="token plain"> = </span><span class="token string" style="color:rgb(206, 145, 120)">"((RecipientTypeDetails -eq 'SharedMailbox') -or (RecipientTypeDetails -eq 'RoomMailbox') -or (RecipientTypeDetails -eq 'EquipmentMailbox') -or (RecipientTypeDetails -eq 'GroupMailbox') -or (RecipientTypeDetails -eq 'TeamMailbox'))"</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(212, 212, 212)">}</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(212, 212, 212)">}</span><br></div></code></pre></div></div>
<h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="get-last-login-time">Get last login time.<a href="https://homotechsual.dev/2022/09/07/Connecting-Exchange-Online-Delegated-REST#get-last-login-time" class="hash-link" aria-label="Direct link to Get last login time." title="Direct link to Get last login time." translate="no">​</a></h3>
<div class="language-powershell codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#9CDCFE;--prism-background-color:#1E1E1E"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-powershell codeBlock_bY9V thin-scrollbar" style="color:#9CDCFE;background-color:#1E1E1E"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#9CDCFE"><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><span class="token plain">\</span><span class="token function" style="color:rgb(220, 220, 170)">Invoke-EORESTDelegated</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><span class="token plain">ps1 @EORESTParameters </span><span class="token operator" style="color:rgb(212, 212, 212)">-</span><span class="token plain">ScriptBlock </span><span class="token punctuation" style="color:rgb(212, 212, 212)">{</span><span class="token plain"></span><br></div><div class="token-line" style="color:#9CDCFE"><span class="token plain">  </span><span class="token variable" style="color:rgb(156, 220, 254)">$Mailboxes</span><span class="token plain"> = </span><span class="token function" style="color:rgb(220, 220, 170)">Invoke-EORequest</span><span class="token plain"> </span><span class="token operator" style="color:rgb(212, 212, 212)">-</span><span class="token plain">Commandlet </span><span class="token string" style="color:rgb(206, 145, 120)">'Get-Mailbox'</span><span class="token plain"> </span><span class="token operator" style="color:rgb(212, 212, 212)">-</span><span class="token plain">Parameters @</span><span class="token punctuation" style="color:rgb(212, 212, 212)">{</span><span class="token plain"> ResultSize = </span><span class="token string" style="color:rgb(206, 145, 120)">'Unlimited'</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(212, 212, 212)">}</span><span class="token plain"></span><br></div><div class="token-line" style="color:#9CDCFE"><span class="token plain">  </span><span class="token keyword" style="color:rgb(86, 156, 214)">ForEach</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(212, 212, 212)">(</span><span class="token variable" style="color:rgb(156, 220, 254)">$Mailbox</span><span class="token plain"> in </span><span class="token variable" style="color:rgb(156, 220, 254)">$Mailboxes</span><span class="token punctuation" style="color:rgb(212, 212, 212)">)</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(212, 212, 212)">{</span><span class="token plain"> </span><span class="token function" style="color:rgb(220, 220, 170)">Invoke-EORequest</span><span class="token plain"> </span><span class="token operator" style="color:rgb(212, 212, 212)">-</span><span class="token plain">Commandlet </span><span class="token string" style="color:rgb(206, 145, 120)">'Get-MailboxStatistics'</span><span class="token plain"> </span><span class="token operator" style="color:rgb(212, 212, 212)">-</span><span class="token plain">Parameters @</span><span class="token punctuation" style="color:rgb(212, 212, 212)">{</span><span class="token plain"> Identity = </span><span class="token variable" style="color:rgb(156, 220, 254)">$Mailbox</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><span class="token plain">UserPrincipalName </span><span class="token punctuation" style="color:rgb(212, 212, 212)">}</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(212, 212, 212)">|</span><span class="token plain"> </span><span class="token function" style="color:rgb(220, 220, 170)">Select-Object</span><span class="token plain"> </span><span class="token operator" style="color:rgb(212, 212, 212)">-</span><span class="token plain">Property DisplayName</span><span class="token punctuation" style="color:rgb(212, 212, 212)">,</span><span class="token plain"> LastLoggedOnUserAccount</span><span class="token punctuation" style="color:rgb(212, 212, 212)">,</span><span class="token plain"> LastLogonTime </span><span class="token punctuation" style="color:rgb(212, 212, 212)">}</span><span class="token plain"></span><br></div><div class="token-line" style="color:#9CDCFE"><span class="token plain"></span><span class="token punctuation" style="color:rgb(212, 212, 212)">}</span><br></div></code></pre></div></div>
<h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="get-mailboxes-not-logged-into-in-the-last-90-days">Get mailboxes not logged into in the last 90 days.<a href="https://homotechsual.dev/2022/09/07/Connecting-Exchange-Online-Delegated-REST#get-mailboxes-not-logged-into-in-the-last-90-days" class="hash-link" aria-label="Direct link to Get mailboxes not logged into in the last 90 days." title="Direct link to Get mailboxes not logged into in the last 90 days." translate="no">​</a></h3>
<div class="language-powershell codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#9CDCFE;--prism-background-color:#1E1E1E"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-powershell codeBlock_bY9V thin-scrollbar" style="color:#9CDCFE;background-color:#1E1E1E"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#9CDCFE"><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><span class="token plain">\</span><span class="token function" style="color:rgb(220, 220, 170)">Invoke-EORESTDelegated</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><span class="token plain">ps1 @EORESTParameters </span><span class="token operator" style="color:rgb(212, 212, 212)">-</span><span class="token plain">ScriptBlock </span><span class="token punctuation" style="color:rgb(212, 212, 212)">{</span><span class="token plain"></span><br></div><div class="token-line" style="color:#9CDCFE"><span class="token plain">  </span><span class="token variable" style="color:rgb(156, 220, 254)">$Mailboxes</span><span class="token plain"> = </span><span class="token function" style="color:rgb(220, 220, 170)">Invoke-EORequest</span><span class="token plain"> </span><span class="token operator" style="color:rgb(212, 212, 212)">-</span><span class="token plain">Commandlet </span><span class="token string" style="color:rgb(206, 145, 120)">'Get-Mailbox'</span><span class="token plain"> </span><span class="token operator" style="color:rgb(212, 212, 212)">-</span><span class="token plain">Parameters @</span><span class="token punctuation" style="color:rgb(212, 212, 212)">{</span><span class="token plain"> ResultSize = </span><span class="token string" style="color:rgb(206, 145, 120)">'Unlimited'</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(212, 212, 212)">}</span><span class="token plain"></span><br></div><div class="token-line" style="color:#9CDCFE"><span class="token plain">  </span><span class="token keyword" style="color:rgb(86, 156, 214)">ForEach</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(212, 212, 212)">(</span><span class="token variable" style="color:rgb(156, 220, 254)">$Mailbox</span><span class="token plain"> in </span><span class="token variable" style="color:rgb(156, 220, 254)">$Mailboxes</span><span class="token punctuation" style="color:rgb(212, 212, 212)">)</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(212, 212, 212)">{</span><span class="token plain"> </span><span class="token function" style="color:rgb(220, 220, 170)">Invoke-EORequest</span><span class="token plain"> </span><span class="token operator" style="color:rgb(212, 212, 212)">-</span><span class="token plain">Commandlet </span><span class="token string" style="color:rgb(206, 145, 120)">'Get-MailboxStatistics'</span><span class="token plain"> </span><span class="token operator" style="color:rgb(212, 212, 212)">-</span><span class="token plain">Parameters @</span><span class="token punctuation" style="color:rgb(212, 212, 212)">{</span><span class="token plain"> Identity = </span><span class="token variable" style="color:rgb(156, 220, 254)">$Mailbox</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><span class="token plain">UserPrincipalName </span><span class="token punctuation" style="color:rgb(212, 212, 212)">}</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(212, 212, 212)">|</span><span class="token plain"> </span><span class="token function" style="color:rgb(220, 220, 170)">Where-Object</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(212, 212, 212)">{</span><span class="token plain"> </span><span class="token variable" style="color:rgb(156, 220, 254)">$_</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><span class="token plain">LastLogonTime </span><span class="token operator" style="color:rgb(212, 212, 212)">-lt</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(212, 212, 212)">(</span><span class="token function" style="color:rgb(220, 220, 170)">Get-Date</span><span class="token punctuation" style="color:rgb(212, 212, 212)">)</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><span class="token plain">AddDays</span><span class="token punctuation" style="color:rgb(212, 212, 212)">(</span><span class="token operator" style="color:rgb(212, 212, 212)">-</span><span class="token plain">90</span><span class="token punctuation" style="color:rgb(212, 212, 212)">)</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(212, 212, 212)">}</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(212, 212, 212)">|</span><span class="token plain"> </span><span class="token function" style="color:rgb(220, 220, 170)">Select-Object</span><span class="token plain"> </span><span class="token operator" style="color:rgb(212, 212, 212)">-</span><span class="token plain">Property DisplayName</span><span class="token punctuation" style="color:rgb(212, 212, 212)">,</span><span class="token plain"> LastLoggedOnUserAccount</span><span class="token punctuation" style="color:rgb(212, 212, 212)">,</span><span class="token plain"> LastLogonTime </span><span class="token punctuation" style="color:rgb(212, 212, 212)">}</span><span class="token plain"></span><br></div><div class="token-line" style="color:#9CDCFE"><span class="token plain"></span><span class="token punctuation" style="color:rgb(212, 212, 212)">}</span><br></div></code></pre></div></div>
<h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="get-inactive-mailboxes">Get inactive mailboxes.<a href="https://homotechsual.dev/2022/09/07/Connecting-Exchange-Online-Delegated-REST#get-inactive-mailboxes" class="hash-link" aria-label="Direct link to Get inactive mailboxes." title="Direct link to Get inactive mailboxes." translate="no">​</a></h3>
<div class="language-powershell codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#9CDCFE;--prism-background-color:#1E1E1E"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-powershell codeBlock_bY9V thin-scrollbar" style="color:#9CDCFE;background-color:#1E1E1E"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#9CDCFE"><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><span class="token plain">\</span><span class="token function" style="color:rgb(220, 220, 170)">Invoke-EORESTDelegated</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><span class="token plain">ps1 @EORESTParameters </span><span class="token operator" style="color:rgb(212, 212, 212)">-</span><span class="token plain">ScriptBlock </span><span class="token punctuation" style="color:rgb(212, 212, 212)">{</span><span class="token plain"></span><br></div><div class="token-line" style="color:#9CDCFE"><span class="token plain">  </span><span class="token function" style="color:rgb(220, 220, 170)">Invoke-EORequest</span><span class="token plain"> </span><span class="token operator" style="color:rgb(212, 212, 212)">-</span><span class="token plain">Commandlet </span><span class="token string" style="color:rgb(206, 145, 120)">'Get-Mailbox'</span><span class="token plain"> </span><span class="token operator" style="color:rgb(212, 212, 212)">-</span><span class="token plain">Parameters @</span><span class="token punctuation" style="color:rgb(212, 212, 212)">{</span><span class="token plain"> InactiveMailboxOnly = </span><span class="token boolean">$True</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(212, 212, 212)">}</span><span class="token plain"></span><br></div><div class="token-line" style="color:#9CDCFE"><span class="token plain"></span><span class="token punctuation" style="color:rgb(212, 212, 212)">}</span><br></div></code></pre></div></div>
<h3 class="anchor anchorTargetStickyNavbar_Vzrq" id="set-hidden-from-address-list-for-all-mailboxes">Set hidden from address list for all mailboxes.<a href="https://homotechsual.dev/2022/09/07/Connecting-Exchange-Online-Delegated-REST#set-hidden-from-address-list-for-all-mailboxes" class="hash-link" aria-label="Direct link to Set hidden from address list for all mailboxes." title="Direct link to Set hidden from address list for all mailboxes." translate="no">​</a></h3>
<div class="language-powershell codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#9CDCFE;--prism-background-color:#1E1E1E"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-powershell codeBlock_bY9V thin-scrollbar" style="color:#9CDCFE;background-color:#1E1E1E"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#9CDCFE"><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><span class="token plain">\</span><span class="token function" style="color:rgb(220, 220, 170)">Invoke-EORESTDelegated</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><span class="token plain">ps1 @EORESTParameters </span><span class="token operator" style="color:rgb(212, 212, 212)">-</span><span class="token plain">ScriptBlock </span><span class="token punctuation" style="color:rgb(212, 212, 212)">{</span><span class="token plain"></span><br></div><div class="token-line" style="color:#9CDCFE"><span class="token plain">  </span><span class="token variable" style="color:rgb(156, 220, 254)">$Mailboxes</span><span class="token plain"> = </span><span class="token function" style="color:rgb(220, 220, 170)">Invoke-EORequest</span><span class="token plain"> </span><span class="token operator" style="color:rgb(212, 212, 212)">-</span><span class="token plain">Commandlet </span><span class="token string" style="color:rgb(206, 145, 120)">'Get-Mailbox'</span><span class="token plain"> </span><span class="token operator" style="color:rgb(212, 212, 212)">-</span><span class="token plain">Parameters @</span><span class="token punctuation" style="color:rgb(212, 212, 212)">{</span><span class="token plain"> ResultSize = </span><span class="token string" style="color:rgb(206, 145, 120)">'Unlimited'</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(212, 212, 212)">}</span><span class="token plain"></span><br></div><div class="token-line" style="color:#9CDCFE"><span class="token plain">  </span><span class="token keyword" style="color:rgb(86, 156, 214)">ForEach</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(212, 212, 212)">(</span><span class="token variable" style="color:rgb(156, 220, 254)">$Mailbox</span><span class="token plain"> in </span><span class="token variable" style="color:rgb(156, 220, 254)">$Mailboxes</span><span class="token punctuation" style="color:rgb(212, 212, 212)">)</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(212, 212, 212)">{</span><span class="token plain"> </span><span class="token function" style="color:rgb(220, 220, 170)">Invoke-EORequest</span><span class="token plain"> </span><span class="token operator" style="color:rgb(212, 212, 212)">-</span><span class="token plain">Commandlet </span><span class="token string" style="color:rgb(206, 145, 120)">'Set-Mailbox'</span><span class="token plain"> </span><span class="token operator" style="color:rgb(212, 212, 212)">-</span><span class="token plain">Parameters @</span><span class="token punctuation" style="color:rgb(212, 212, 212)">{</span><span class="token plain"> Identity = </span><span class="token variable" style="color:rgb(156, 220, 254)">$Mailbox</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><span class="token plain">UserPrincipalName</span><span class="token punctuation" style="color:rgb(212, 212, 212)">;</span><span class="token plain"> HiddenFromAddressListEnabled = </span><span class="token boolean">$True</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(212, 212, 212)">}</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(212, 212, 212)">}</span><span class="token plain"></span><br></div><div class="token-line" style="color:#9CDCFE"><span class="token plain"></span><span class="token punctuation" style="color:rgb(212, 212, 212)">}</span><br></div></code></pre></div></div>]]></content:encoded>
            <category>PowerShell</category>
            <category>Exchange Online</category>
            <category>Microsoft 365</category>
            <category>REST</category>
            <category>Scripting</category>
        </item>
        <item>
            <title><![CDATA[Finding duplicate devices in NinjaOne]]></title>
            <link>https://homotechsual.dev/2022/04/12/Finding-duplicate-devices-NinjaOne</link>
            <guid>https://homotechsual.dev/2022/04/12/Finding-duplicate-devices-NinjaOne</guid>
            <pubDate>Tue, 12 Apr 2022 00:00:00 GMT</pubDate>
            <description><![CDATA[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.]]></description>
            <content:encoded><![CDATA[<p>I'm the author of the <a href="https://github.com/homotechsual/NinjaOne" target="_blank" rel="noopener noreferrer" class="">NinjaOne</a> 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.</p>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="about-this-script">About this script<a href="https://homotechsual.dev/2022/04/12/Finding-duplicate-devices-NinjaOne#about-this-script" class="hash-link" aria-label="Direct link to About this script" title="Direct link to About this script" translate="no">​</a></h2>
<p>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.</p>
<!-- -->
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="the-script">The script<a href="https://homotechsual.dev/2022/04/12/Finding-duplicate-devices-NinjaOne#the-script" class="hash-link" aria-label="Direct link to The script" title="Direct link to The script" translate="no">​</a></h2>
<div class="docusaurus-theme-github-codeblock"><div class="language-powershell codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#9CDCFE;--prism-background-color:#1E1E1E"><div class="codeBlockTitle_OeMC">Get-NinjaOneDuplicateDevices.ps1</div><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-powershell codeBlock_bY9V thin-scrollbar" style="color:#9CDCFE;background-color:#1E1E1E"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#9CDCFE"><span class="token plain">loading</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><br></div></code></pre></div></div><div style="font-size:.9em;font-weight:600;color:#0E75DD;text-align:right;padding-bottom:13px;text-decoration:underline"><a href="https://github.com/homotechsual/Blog-Scripts/blob/main/NinjaOne%20API/GetDuplicateDevices.ps1" class="githubLink" style="margin:0 10px" target="_blank">View on GitHub</a></div></div>
<p>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.</p>
<p>If you want all devices with duplicates:</p>
<p><code>Get-NinjaOneDuplicateDevices -All</code></p>
<p>or just the older duplicated devices:</p>
<p><code>Get-NinjaOneDuplicateDevices -Duplicates</code></p>]]></content:encoded>
            <category>PowerShell</category>
            <category>NinjaOne</category>
            <category>Duplicate</category>
            <category>RMM</category>
            <category>Scripting</category>
        </item>
        <item>
            <title><![CDATA[Recursively remove a folder from OneDrive with PowerShell]]></title>
            <link>https://homotechsual.dev/2022/04/10/Recursively-Remove-Folder-OneDrive</link>
            <guid>https://homotechsual.dev/2022/04/10/Recursively-Remove-Folder-OneDrive</guid>
            <pubDate>Sun, 10 Apr 2022 00:00:00 GMT</pubDate>
            <description><![CDATA[Did you know, when you have a retention policy configured for OneDrive in Microsoft 365 you lose the ability to recursively delete folders. The OneDrive client often handles this by recursing through the folder tree to remove the online copies but sometimes that doesn't work and in those cases you can end up stuck with a folder tree that you would have to manually recurse to remove the offending folders by first emptying them entirely before OneDrive will let you delete them.]]></description>
            <content:encoded><![CDATA[<p>Did you know, when you have a retention policy configured for OneDrive in Microsoft 365 you lose the ability to recursively delete folders. The OneDrive client often handles this by recursing through the folder tree to remove the online copies but sometimes that doesn't work and in those cases you can end up stuck with a folder tree that you would have to manually recurse to remove the offending folders by first emptying them entirely before OneDrive will let you delete them.</p>
<p>Well that's never going to happen ;-)</p>
<p>Enter PowerShell.</p>
<p>:::info Required Modules
You'll need the <code>PnP.PowerShell</code> module for this script. Install with <code>Install-Module 'PnP.PowerShell'</code>
:::</p>
<!-- -->
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="the-script">The script<a href="https://homotechsual.dev/2022/04/10/Recursively-Remove-Folder-OneDrive#the-script" class="hash-link" aria-label="Direct link to The script" title="Direct link to The script" translate="no">​</a></h2>
<div class="docusaurus-theme-github-codeblock"><div class="language-powershell codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#9CDCFE;--prism-background-color:#1E1E1E"><div class="codeBlockTitle_OeMC">Remove-OneDriveFolderRecursively.ps1</div><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-powershell codeBlock_bY9V thin-scrollbar" style="color:#9CDCFE;background-color:#1E1E1E"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#9CDCFE"><span class="token plain">loading</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><br></div></code></pre></div></div><div style="font-size:.9em;font-weight:600;color:#0E75DD;text-align:right;padding-bottom:13px;text-decoration:underline"><a href="https://github.com/homotechsual/Blog-Scripts/blob/main/Microsoft%20365/OneDrive/RemoveFolderRecursively.ps1" class="githubLink" style="margin:0 10px" target="_blank">View on GitHub</a></div></div>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="invoking-the-script">Invoking the script<a href="https://homotechsual.dev/2022/04/10/Recursively-Remove-Folder-OneDrive#invoking-the-script" class="hash-link" aria-label="Direct link to Invoking the script" title="Direct link to Invoking the script" translate="no">​</a></h2>
<p>The script is looking for three parameters, an example invocation to remove a synced "Documents/PowerShell/Modules" folder in Satya Nadella's OneDrive would be:</p>
<p>:::tip Double the Documents
You'll notice below that the <code>/Documents</code> folder in the path is doubled. This is because the first folder in the OneDrive path is always <code>/Documents</code> then your path starts. In this example we're removing the <code>/Documents/PowerShell/Modules</code> folder.
:::</p>
<div class="language-powershell codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#9CDCFE;--prism-background-color:#1E1E1E"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-powershell codeBlock_bY9V thin-scrollbar" style="color:#9CDCFE;background-color:#1E1E1E"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#9CDCFE"><span class="token function" style="color:rgb(220, 220, 170)">Remove-OneDriveFolderRecursively</span><span class="token plain"> </span><span class="token operator" style="color:rgb(212, 212, 212)">-</span><span class="token plain">OneDriveHost </span><span class="token string" style="color:rgb(206, 145, 120)">'https://microsoft-my.sharepoint.com'</span><span class="token plain"> </span><span class="token operator" style="color:rgb(212, 212, 212)">-</span><span class="token plain">SitePath </span><span class="token string" style="color:rgb(206, 145, 120)">'/personal/satya_nadella_microsoft_com'</span><span class="token plain"> </span><span class="token operator" style="color:rgb(212, 212, 212)">-</span><span class="token plain">FolderPath </span><span class="token string" style="color:rgb(206, 145, 120)">'/Documents/Documents/PowerShell/Modules'</span><br></div></code></pre></div></div>
<p>Hope this helps!</p>
<p>This post was inspired by <a href="https://techcommunity.microsoft.com/t5/windows-powershell/how-to-use-powershell-to-remove-nonempty-folder-in-onedrive/m-p/2262976" target="_blank" rel="noopener noreferrer" class="">a script posted on Microsoft's TechCommunity here...</a></p>]]></content:encoded>
            <category>OneDrive</category>
            <category>Scripting</category>
            <category>PowerShell</category>
            <category>PnP.PowerShell</category>
        </item>
        <item>
            <title><![CDATA[Getting-computer-information-NinjaOne-agent-HaloPSA]]></title>
            <link>https://homotechsual.dev/2022/01/22/Getting-computer-information-NinjaOne-agent-HaloPSA</link>
            <guid>https://homotechsual.dev/2022/01/22/Getting-computer-information-NinjaOne-agent-HaloPSA</guid>
            <pubDate>Sat, 22 Jan 2022 00:00:00 GMT</pubDate>
            <description><![CDATA[*]]></description>
            <content:encoded><![CDATA[<hr>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="title-getting-computer-information-from-your-ninjaone-agent-into-your-halopsa-self-service-portalauthors-mikeytags--halopsa-ninjaone-powershell-">title: Getting computer information from your NinjaOne agent into your HaloPSA self service portal
authors: mikey
tags: [ HaloPSA, NinjaOne, PowerShell ]<a href="https://homotechsual.dev/2022/01/22/Getting-computer-information-NinjaOne-agent-HaloPSA#title-getting-computer-information-from-your-ninjaone-agent-into-your-halopsa-self-service-portalauthors-mikeytags--halopsa-ninjaone-powershell-" class="hash-link" aria-label="Direct link to title: Getting computer information from your NinjaOne agent into your HaloPSA self service portal
authors: mikey
tags: [ HaloPSA, NinjaOne, PowerShell ]" title="Direct link to title: Getting computer information from your NinjaOne agent into your HaloPSA self service portal
authors: mikey
tags: [ HaloPSA, NinjaOne, PowerShell ]" translate="no">​</a></h2>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="background-information">Background information<a href="https://homotechsual.dev/2022/01/22/Getting-computer-information-NinjaOne-agent-HaloPSA#background-information" class="hash-link" aria-label="Direct link to Background information" title="Direct link to Background information" translate="no">​</a></h2>
<p>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.</p>
<!-- -->
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="getting-halopsa-ready">Getting HaloPSA ready<a href="https://homotechsual.dev/2022/01/22/Getting-computer-information-NinjaOne-agent-HaloPSA#getting-halopsa-ready" class="hash-link" aria-label="Direct link to Getting HaloPSA ready" title="Direct link to Getting HaloPSA ready" translate="no">​</a></h2>
<p>For this to work we're relying on a feature which Halo released in version 2.73, now this might not be available to you considering 2.72 is the current stable. Still - let's see how we do this and then when you have 2.73 or greater you can configure this yourself.</p>
<p>:::note Halo release notes for this feature...</p>
<p>You can use URI parameters in the self-service portal to set the default value of text custom fields on the new ticket screen
Add <code>&amp;customfield_{id}</code> to the URL with <code>{id}</code> replaced with the id of the custom field.</p>
<p><code>https://myhalourl/portal/newticket?tickettype_id=1&amp;customfield_174=text%20test</code> would set custom field with ID <code>174</code> to <em>"text test"</em> by default.</p>
<p>:::</p>
<p>Now that we know how it works - we'll need to add some custom fields to a ticket form in order to get this to work. First though, let's step back a second and check what information we can send from Ninja's agent...</p>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="what-can-ninjaone-provide-to-halo">What can NinjaOne provide to Halo?<a href="https://homotechsual.dev/2022/01/22/Getting-computer-information-NinjaOne-agent-HaloPSA#what-can-ninjaone-provide-to-halo" class="hash-link" aria-label="Direct link to What can NinjaOne provide to Halo?" title="Direct link to What can NinjaOne provide to Halo?" translate="no">​</a></h2>
<p>We can find the information on what variables NinjaOne provides for use in the various system tray items in this <a href="https://ninjarmm.zendesk.com/hc/en-us/articles/115001717823-Branding-Systray-Icon#h_f62b4631-720e-4bcd-8dec-4d669c6c0d35" target="_blank" rel="noopener noreferrer" class="">NinjaDojo article</a>. The available variables differ depending on what you're adding to the tray icon, we're interested in <strong>Placeholders for Menu Items</strong>. These are:</p>
<ul>
<li class=""><code>${IP_ADDR}</code> - IP Address</li>
<li class=""><code>${USERNAME}</code> - Username of current user</li>
<li class=""><code>${HOSTNAME}</code> - Machine hostname</li>
<li class=""><code>${DOMAIN}</code> - Domain that the machine has joined</li>
<li class=""><code>${TIMESTAMP}</code> - Current timestamp in ISO format (UTC)</li>
<li class="">Any other environment variable - for example <code>${PROCESSOR_ARCHITECTURE}</code></li>
</ul>
<p>That last one is pretty important, <em>any environment variable</em> - so what information might that include? Run <code>Get-ChildItem ENV:</code> in a PowerShell session to get a list of currently available environment variables. Useful environment variables include <code>${COMPUTERNAME}</code> but it's also worth noting that you can set environment variables from your NinjaOne scripts - we often set environment variables that indicate the state of key components - e.g. OneDrive status.</p>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="back-to-setting-up-halopsa">Back to setting up HaloPSA<a href="https://homotechsual.dev/2022/01/22/Getting-computer-information-NinjaOne-agent-HaloPSA#back-to-setting-up-halopsa" class="hash-link" aria-label="Direct link to Back to setting up HaloPSA" title="Direct link to Back to setting up HaloPSA" translate="no">​</a></h2>
<p>So back to HaloPSA, we're heading to <strong>Configuration -&gt; Tickets -&gt; Ticket Types</strong> selecting the ticket type we want our users to create from the NinjaOne tray, in our example we're going to use <em>Incident</em> - make sure you check the URL for the <code>tickettypeid</code> which for ours, in our example, is <code>1</code>.</p>
<p>Click on <strong>Field List</strong> then click on <strong>Edit</strong> and finally <strong>Add</strong>, you'll be presented with a popup that lets you select existing Field Groups or add new ones using the <strong>Add</strong> button.</p>
<p>We're going to create a <strong>Field Group</strong> to hold our fields which will be coming from NinjaOne. So we're going to click on <strong>New</strong> on the Field Groups page, we're going to enter a name, in our case we're calling this <em>NinjaOne</em> and we're inputting a Group Header to mark these fields on the form as <em>Device Information</em>.</p>
<p>Save your field group then click on <strong>Field List</strong> and click <strong>Edit</strong>. We're going to add some fields using <strong>Add</strong>.</p>
<p>You'll see all custom fields available to you here to add to your group, many of the ones you want are probably already there, if not - go to <strong>Configuration -&gt; Custom Objects -&gt; Custom Fields</strong> and add new fields to the Ticket entity.</p>
<p>In our example we're adding a custom field called <code>Computer Name</code></p>
<p><img decoding="async" loading="lazy" alt="Adding a Custom Field to HaloPSA" src="https://homotechsual.dev/assets/images/NinjaHaloSysTrayCustomField-ad95bfff9e3a2694af905a8fa88765e8.png" width="971" height="311" class="img_ev3q"></p>
<p>Make sure when you add a field that you grab the field id from the URL, in our case this was <code>170</code>. Once we've added the field(s) it should look like this:</p>
<p><img decoding="async" loading="lazy" alt="Field Group with some fields added" src="https://homotechsual.dev/assets/images/NinjaHaloSysTrayFieldGroup-e914d789e75eda517537c6677f61875d.png" width="1161" height="255" class="img_ev3q"></p>
<p>Let's pop onto the portal and check whether the field shows up, it does! Great! Now if we didn't get the ID previously we can right click the field, hit <strong>Inspect Element</strong> and grab the number from the end of the <code>id</code> attribute.</p>
<p>So, we know we want a link to create a ticket (of type id <code>1</code>) which fills in custom field (with id <code>170</code>) with the value of <code>${COMPUTERNAME}</code> from NinjaOne. So let's string that together ready for NinjaOne...</p>
<p><code>https://yourhalo.portal.example/newticket?tickettype_id=1&amp;customfield_170=${COMPUTERNAME}</code></p>
<p>That's it - that's our link, if we wanted to add more custom fields we just append them to the end <code>&amp;customfield_nnn=${variable}</code>.</p>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="adding-the-link-to-the-systray-icon">Adding the link to the SysTray icon<a href="https://homotechsual.dev/2022/01/22/Getting-computer-information-NinjaOne-agent-HaloPSA#adding-the-link-to-the-systray-icon" class="hash-link" aria-label="Direct link to Adding the link to the SysTray icon" title="Direct link to Adding the link to the SysTray icon" translate="no">​</a></h2>
<p>So we're going to head to <strong>Configuration -&gt; Branding -&gt; Systray Icon</strong> in NinjaOne and <strong>Add Menu Item</strong>, we want type <em>URL</em>, we're going to give it the label <em>Open a Service Desk ticket...</em>, we're going to pop our URL from earlier in and then hit <strong>Save</strong>.</p>
<p>That's it!</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Sending emails using Microsoft Graph and PowerShell]]></title>
            <link>https://homotechsual.dev/2021/12/06/Sending-emails-using-Microsoft-Graph-PowerShell</link>
            <guid>https://homotechsual.dev/2021/12/06/Sending-emails-using-Microsoft-Graph-PowerShell</guid>
            <pubDate>Mon, 06 Dec 2021 00:00:00 GMT</pubDate>
            <description><![CDATA[I've released another PowerShell module; this one is called MSGraphMail and it's a simple PowerShell Graph API email client implementation which was requested by one of our MSP customers to help with transitioning their setup from a legacy SMTP server to Microsoft 365 without redeveloping a very bespoke workflow!]]></description>
            <content:encoded><![CDATA[<p>I've released another PowerShell module; this one is called <a href="https://github.com/homotechsual/MSGraphMail" target="_blank" rel="noopener noreferrer" class="">MSGraphMail</a> and it's a simple PowerShell Graph API email client implementation which was requested by one of our MSP customers to help with transitioning their setup from a legacy SMTP server to Microsoft 365 without redeveloping a very bespoke workflow!</p>
]]></content:encoded>
            <category>Exchange Online</category>
            <category>Microsoft Graph</category>
            <category>PowerShell</category>
        </item>
        <item>
            <title><![CDATA[Pushing a web tab into your Customers' Teams environment.]]></title>
            <link>https://homotechsual.dev/2021/11/25/Pushing-web-tab-Customers-Teams-environment</link>
            <guid>https://homotechsual.dev/2021/11/25/Pushing-web-tab-Customers-Teams-environment</guid>
            <pubDate>Thu, 25 Nov 2021 00:00:00 GMT</pubDate>
            <description><![CDATA[About this script]]></description>
            <content:encoded><![CDATA[<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="about-this-script">About this script<a href="https://homotechsual.dev/2021/11/25/Pushing-web-tab-Customers-Teams-environment#about-this-script" class="hash-link" aria-label="Direct link to About this script" title="Direct link to About this script" translate="no">​</a></h2>
<p><a href="https://halopsa.com/" target="_blank" rel="noopener noreferrer" class="">HaloPSA</a> is improving at a phenomenal rate - one of the latest enhancements relates to embedding the "customer portal" inside Teams for easier access by customers - this is early days for this enhancement to Halo and at present there isn't really a way to push this tab into customer environments... Until now!</p>
<p>Using the script below you can push any website as a tab to your customers' Teams environments. First a couple of configuration pre-requisites.</p>
<ol>
<li class="">You'll need to have <a href="https://www.gavsto.com/secure-application-model-for-the-layman-and-step-by-step/" target="_blank" rel="noopener noreferrer" class="">setup the Secure App Model</a> (Thanks Gav for the superb write-up!)</li>
<li class="">You'll need to know the name of the Team and Channel you want to deploy the tab - currently the script will use the same details for all customers!</li>
</ol>
<!-- -->
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="the-fix">The fix<a href="https://homotechsual.dev/2021/11/25/Pushing-web-tab-Customers-Teams-environment#the-fix" class="hash-link" aria-label="Direct link to The fix" title="Direct link to The fix" translate="no">​</a></h2>
<div class="theme-admonition theme-admonition-security admonition_Gfwi alert alert--security"><div class="admonitionHeading_f1Ed"><span class="admonitionIcon_kpSf"><svg data-prefix="fas" data-icon="shield-halved" class="svg-inline--fa fa-shield-halved" role="img" viewBox="0 0 512 512" aria-hidden="true"><path fill="currentColor" d="M256 0c4.6 0 9.2 1 13.4 2.9L457.8 82.8c22 9.3 38.4 31 38.3 57.2-.5 99.2-41.3 280.7-213.6 363.2-16.7 8-36.1 8-52.8 0-172.4-82.5-213.1-264-213.6-363.2-.1-26.2 16.3-47.9 38.3-57.2L242.7 2.9C246.9 1 251.4 0 256 0zm0 66.8l0 378.1c138-66.8 175.1-214.8 176-303.4l-176-74.6 0 0z"></path></svg></span>Securing Credentials in Scripts</div><div class="admonitionContent_UjKb">Do not store credentials directly in scripts. You should utilise services like Azure KeyVault or other PAM solutions to secure credentials used in scripts, including this one.</div></div>
<div class="theme-admonition theme-admonition-tip admonition_Gfwi alert alert--success"><div class="admonitionHeading_f1Ed"><span class="admonitionIcon_kpSf"><svg data-prefix="fas" data-icon="lightbulb" class="svg-inline--fa fa-lightbulb" role="img" viewBox="0 0 384 512" aria-hidden="true"><path fill="currentColor" d="M292.9 384c7.3-22.3 21.9-42.5 38.4-59.9 32.7-34.4 52.7-80.9 52.7-132.1 0-106-86-192-192-192S0 86 0 192c0 51.2 20 97.7 52.7 132.1 16.5 17.4 31.2 37.6 38.4 59.9l201.7 0zM288 432l-192 0 0 16c0 44.2 35.8 80 80 80l32 0c44.2 0 80-35.8 80-80l0-16zM184 112c-39.8 0-72 32.2-72 72 0 13.3-10.7 24-24 24s-24-10.7-24-24c0-66.3 53.7-120 120-120 13.3 0 24 10.7 24 24s-10.7 24-24 24z"></path></svg></span>This Script Was Updated</div><div class="admonitionContent_UjKb"><p>This script was updated after being published, if you're using it please compare the version you have with the version available here.</p><p>This script was last updated on <!-- -->2023/03/25<!-- -->.</p></div></div>
<p>So here's the script:</p>
<div class="docusaurus-theme-github-codeblock"><div class="language-powershell codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#9CDCFE;--prism-background-color:#1E1E1E"><div class="codeBlockTitle_OeMC">New-TeamsWebTab.ps1</div><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-powershell codeBlock_bY9V thin-scrollbar" style="color:#9CDCFE;background-color:#1E1E1E"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#9CDCFE"><span class="token plain">loading</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><br></div></code></pre></div></div><div style="font-size:.9em;font-weight:600;color:#0E75DD;text-align:right;padding-bottom:13px;text-decoration:underline"><a href="https://github.com/homotechsual/Blog-Scripts/blob/main/Microsoft%20365/Teams/WebTabForPartners.ps1" class="githubLink" style="margin:0 10px" target="_blank">View on GitHub</a></div></div>
<p>To invoke the script we need to satisfy it's required parameters, an example invocation would look like this:</p>
<div class="language-powershell codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#9CDCFE;--prism-background-color:#1E1E1E"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-powershell codeBlock_bY9V thin-scrollbar" style="color:#9CDCFE;background-color:#1E1E1E"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#9CDCFE"><span class="token variable" style="color:rgb(156, 220, 254)">$NTWTParams</span><span class="token plain"> = @</span><span class="token punctuation" style="color:rgb(212, 212, 212)">{</span><span class="token plain"></span><br></div><div class="token-line" style="color:#9CDCFE"><span class="token plain">    CustomerExclude = @</span><span class="token punctuation" style="color:rgb(212, 212, 212)">(</span><span class="token string" style="color:rgb(206, 145, 120)">'example1.onmicrosoft.com'</span><span class="token punctuation" style="color:rgb(212, 212, 212)">,</span><span class="token plain"> </span><span class="token string" style="color:rgb(206, 145, 120)">'example2.onmicrosoft.com'</span><span class="token punctuation" style="color:rgb(212, 212, 212)">)</span><span class="token plain"></span><br></div><div class="token-line" style="color:#9CDCFE"><span class="token plain">    TeamName = </span><span class="token string" style="color:rgb(206, 145, 120)">'IT Service Desk'</span><span class="token plain"></span><br></div><div class="token-line" style="color:#9CDCFE"><span class="token plain">    ChannelName = </span><span class="token string" style="color:rgb(206, 145, 120)">'General'</span><span class="token plain"></span><br></div><div class="token-line" style="color:#9CDCFE"><span class="token plain">    ClientId = </span><span class="token string" style="color:rgb(206, 145, 120)">'00000000-0000-0000-0000-000000000000'</span><span class="token plain"></span><br></div><div class="token-line" style="color:#9CDCFE"><span class="token plain">    ClientSecret = </span><span class="token string" style="color:rgb(206, 145, 120)">'00000000-0000-0000-0000-000000000000'</span><span class="token plain"></span><br></div><div class="token-line" style="color:#9CDCFE"><span class="token plain">    TenantId = </span><span class="token string" style="color:rgb(206, 145, 120)">'00000000-0000-0000-0000-000000000000'</span><span class="token plain"></span><br></div><div class="token-line" style="color:#9CDCFE"><span class="token plain">    TabName = </span><span class="token string" style="color:rgb(206, 145, 120)">'Portal'</span><span class="token plain"></span><br></div><div class="token-line" style="color:#9CDCFE"><span class="token plain">    TabURL = </span><span class="token string" style="color:rgb(206, 145, 120)">'https://portal.homotechsual.dev'</span><span class="token plain"></span><br></div><div class="token-line" style="color:#9CDCFE"><span class="token plain"></span><span class="token punctuation" style="color:rgb(212, 212, 212)">}</span><span class="token plain"></span><br></div><div class="token-line" style="color:#9CDCFE"><span class="token plain"></span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><span class="token plain">\</span><span class="token function" style="color:rgb(220, 220, 170)">New-TeamsWebTab</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><span class="token plain">ps1 @NTWTParams</span><br></div></code></pre></div></div>
<p>Breaking down the available parameters:</p>
<ul>
<li class=""><code>-CustomerExclude</code> - An array of customer tenant domains to exclude from the script.</li>
<li class=""><code>-CustomerInclude</code> - An array of customer tenant domains to include in the script.</li>
<li class=""><code>-TeamName</code> - The name of the Team to add the tab to. Defaults to the default team.</li>
<li class=""><code>-ChannelName</code> - The name of the Channel to add the tab to. Defaults to "General".</li>
<li class=""><code>-ClientId</code> - The Client ID of your Secure Application Model App.</li>
<li class=""><code>-ClientSecret</code> - The Client Secret of your Secure Application Model App.</li>
<li class=""><code>-TenantId</code> - The Tenant ID of your partner tenant.</li>
<li class=""><code>-TabName</code> - The name of the tab to add.</li>
<li class=""><code>-TabURL</code> - The URL of the tab to add.</li>
</ul>
<p>Once you've filled in the variables - you simply run the script and wait for the tabs to be added!</p>]]></content:encoded>
            <category>HaloPSA</category>
            <category>CyberDrain</category>
            <category>Intune</category>
            <category>PowerShell</category>
        </item>
    </channel>
</rss>