MDfE – SIMSENblogThings I learn, tools I build, shared with you. Microsoft Intune, Windows, macOS and endpoint security by Simon Hartmann Eriksen.https://www.simsenblog.dk/en-GBMon, 30 Mar 2026 16:00:00 GMTSimple Model for Intune Compliance Enforcementhttps://www.simsenblog.dk/2026/03/30/simple-model-for-intune-compliance-enforcement/https://www.simsenblog.dk/?p=2258A practical approach to introducing compliance enforcement with Microsoft Intune.Mon, 30 Mar 2026 16:00:00 GMT<p>One of the most common challenges when implementing <strong>Conditional Access with “Require compliant device”</strong> is fear.</p> <ul> <li>Fear that devices will suddenly become non-compliant.</li> <li>Fear that users will lose access to Microsoft 365.</li> <li>Fear that legacy machines will break overnight.</li> </ul> <p>Because of this, many organizations delay enforcing compliance for years.<br> But it doesn’t have to be that way.</p> <p>A simple approach is to introduce compliance in <strong>phases</strong>, starting with visibility and moving towards enforcement.</p> <hr> <h2 id="step-1--build-simple-compliance-policies">Step 1 – Build Simple Compliance Policies</h2> <p>Instead of one large compliance policy, split the controls into logical groups.</p> <p>Example structure:</p> <h3 id="1-policy-os-version">1. Policy: OS Version</h3> <ul> <li>WIN_Compliance_OSVersionWIN10-22H2</li> <li>WIN_Compliance_OSVersionWIN11-24H2</li> <li>WIN_Compliance_OSVersionWIN11-25H2</li> </ul> <p>Purpose: Ensure devices are running supported Windows versions.<br> Configured setting: Minimum OS Version</p> <h3 id="2-policy-platform-security-baseline">2. Policy: Platform Security Baseline</h3> <ul> <li>WIN_Compliance_Security</li> </ul> <p>Checks:</p> <ul> <li>BitLocker enabled</li> <li>Secure Boot enabled</li> <li>Code integrity enabled</li> <li>Trusted Platform Module present</li> </ul> <p>These settings verify that <strong>core device security protections are enabled</strong>.</p> <h3 id="3-policy-critical-security-controls">3. Policy: Critical Security Controls</h3> <ul> <li>WIN_Compliance_SecurityCritical</li> </ul> <p>Checks:</p> <ul> <li>Firewall enabled</li> <li>Antivirus enabled</li> <li>Antispyware enabled</li> <li>Defender Antimalware active</li> <li>Real-time protection enabled</li> <li>Defender Antimalware security intelligence up-to-date</li> </ul> <p>These represent security controls required for enterprise protection.</p> <h3 id="4-policy-defender-risk-level">4. Policy: Defender Risk Level</h3> <ul> <li>WIN_Compliance_DefenderSecureScore</li> </ul> <p>Configured setting:</p> <ul> <li>Require the device to be at or under machine risk score: Medium</li> </ul> <h3 id="how-it-could-look-in-intune">How it could look in Intune:</h3> <p><img src="https://www.simsenblog.dk/images/posts/simple-model-for-intune-compliance-enforcement/Screenshot-2026-03-30-at-18.10.08.png" alt="Intune Windows compliance policies split into Defender Secure Score, OS version and Security policies"></p> <hr> <h2 id="step-2--use-the-compliance-grace-period">Step 2 – Use the Compliance Grace Period</h2> <p>Instead of enforcing immediately, configure a grace period.</p> <p>Recommended options:</p> <ul> <li>30 days<br> or</li> <li>60 days</li> </ul> <p>This allows users time to remediate issues before access is blocked.</p> <p>To support this, configure automated email notifications to inform users about their non-compliant status during the grace period.</p> <p>Example notification schedule:</p> <ul> <li>Day 20: First reminder</li> <li>Day 10: Second reminder</li> <li>Day 5: Final warning</li> <li>Day 0: Access blocked</li> </ul> <p>Example behavior:</p> <ul> <li>Day 0: Policy introduced</li> <li>Day 1-30: Device marked non-compliant but access allowed</li> <li>Day 30: Access blocked if not compliant</li> </ul> <p>This approach:</p> <ul> <li>Avoids service disruption</li> <li>Allows IT to monitor impact</li> <li>Gives users time to update or fix devices</li> <li>Reduces Service Desk load by proactively informing users</li> </ul> <hr> <h2 id="step-3--monitor-before-enforcement">Step 3 – Monitor Before Enforcement</h2> <p>During the grace period:<br> Monitor:</p> <ul> <li>Intune compliance reports</li> <li>Defender device risk</li> <li>Conditional Access insights</li> </ul> <p>This gives a clear view of:</p> <ul> <li>How many devices will be blocked</li> <li>Which settings cause non-compliance</li> <li>Which legacy devices need remediation</li> </ul> <hr> <h2 id="step-4--create-remediation-script-to-trigger-security-settings">Step 4 – Create Remediation script to trigger security settings</h2> <p>If you have machines that is not compliant – because it is drifting from policy.<br> Remediation script can be used to enforce policies as another option from the policy itself.<br> Get my Remediation scripts on my Github page</p> <p><a href="https://github.com/Simsen/RemediationScript-CompliancePolicy"><img src="https://www.simsenblog.dk/images/posts/simple-model-for-intune-compliance-enforcement/github-logo.png" alt="RemediationScript-CompliancePolicy on GitHub"></a></p> <hr> <h2 id="why-this-model-works">Why This Model Works</h2> <p>This staged model delivers several benefits:</p> <ul> <li>Reduces risk of sudden lockouts</li> <li>Improves security posture gradually</li> <li>Provides visibility before enforcement</li> <li>Aligns compliance with Conditional Access</li> </ul> <p>Most importantly, it allows organizations to move forward with Zero Trust without disrupting users.</p> Simon Hartmann EriksenIntuneIntuneComplianceDefender: Security Exposure Managementhttps://www.simsenblog.dk/2025/03/27/defender-security-exposure-management/https://www.simsenblog.dk/?p=2033Defender Security Exposure Management gives one real-time view of your security risks and helps you prioritise what to fix first. What it is, and how to start using it.Thu, 27 Mar 2025 09:00:20 GMT<p>In an era where cyber threats are constantly evolving and attacks are becoming more sophisticated, organizations need a central tool to understand and address their security exposures. Defender Security Exposure Management is just that tool – a unified portal that provides a real-time view of risks and helps prioritize key security actions.</p> <h2 id="what-is-defender-security-exposure-management">What is Defender Security Exposure Management?</h2> <p>This new feature is designed to give organizations a real-time view of their security risks and exposures. Rather than focusing solely on known vulnerabilities and patches, Defender Security Exposure Management analyzes the broader security landscape and prioritizes actions based on real risk.</p> <p>Microsoft has already structured a number of initiatives that bring together key security areas so organizations can quickly identify and address the most critical exposures. These initiatives cover areas such as Endpoint Security, Identity Security, Ransomware Protection, and Zero Trust, providing a unified and strategic approach to security management.</p> <h2 id="why-is-this-important">Why is this important?</h2> <p>Traditionally, security teams have worked with static lists of vulnerabilities and compliance requirements. But with the speed at which the threat landscape is evolving, it’s not enough to follow a list from last quarter—organizations need real-time insight and risk-based prioritization.<br> With Defender Security Exposure Management, you can:</p> <ul> <li>Understand and address the most critical security risks first.</li> <li>Minimize the risk of becoming a target for targeted attacks.</li> <li>Streamline security efforts by reducing the noise of less critical alerts.</li> </ul> <h2 id="how-does-it-work">How does it work?</h2> <p>Defender Security Exposure Management integrates directly into Defender for Endpoint and works with a combination of:</p> <ul> <li>Threat intelligence from Microsoft’s extensive security data.</li> <li>Context-based analysis that takes into account the organization’s unique environment.</li> <li>Automated action where recommended actions can be implemented directly from the portal.</li> </ul> <h2 id="attack-path-management-in-defender-security-exposure-management">Attack Path Management in Defender Security Exposure Management</h2> <p>A key feature of Defender Security Exposure Management is Attack Path Management, which allows organizations to identify and visualize potential routes that attackers can exploit to compromise critical assets. By analyzing the correlation between different assets and vulnerabilities, this feature helps understand how an attacker can move through the network to achieve their goals.</p> <h3 id="key-features-of-attack-path-management">Key features of Attack Path Management:</h3> <ul> <li>Attack Path Dashboard: Provides an overview of all identified attack paths in the organization, including the number of attack paths, choke points, and critical assets. This helps understand the organization’s security posture and prioritize security efforts.</li> <li>Choke Points: Identifies key assets where multiple attack paths intersect, making them critical vulnerabilities. By focusing on these choke points, security teams can effectively mitigate risk by addressing high-impact assets and preventing attackers from advancing through multiple paths.</li> <li>Blast Radius: Enables visualization of how compromising one asset can impact other parts of the network. This helps assess the broader consequences of an attack and prioritize mitigation strategies more effectively.</li> </ul> <p><img src="https://www.simsenblog.dk/images/posts/defender-security-exposure-management/Screenshot-2025-03-27-at-09.48.46-1024x874.png" alt="Defender attack path map from a vulnerable device to an Admin account, with the Top Vulnerabilities list of critical CVEs"></p> <p>By implementing Attack Path Management, organizations can shift from a reactive to a proactive security strategy, where they not only focus on individual vulnerabilities, but also understand and disrupt potential attack paths before they are exploited.</p> <p><img src="https://www.simsenblog.dk/images/posts/defender-security-exposure-management/splitter-1024x109.png" alt="Decorative divider of green binary code"></p> <hr> <h3 id="key-initiatives-in-defender-security-exposure-management">Key initiatives in Defender Security Exposure Management</h3> <p>To provide a structured view of an organization’s security posture, Microsoft has brought together a set of initiatives in Defender Security Exposure Management. These initiatives target key security areas and help prioritize efforts across identity, endpoints, IoT, cloud, and Zero Trust strategies.</p> <ol> <li>Endpoint Security <ul> <li>Identifies vulnerable configurations on clients and servers.</li> <li>Provides recommendations for improved endpoint patching and hardening.</li> </ul> </li> <li>Enterprise IoT Security <ul> <li>Monitors connected devices for security risks and unknown activity.</li> <li>Secures IoT devices with policy-based restrictions and threat isolation.</li> </ul> </li> <li>Identity Security <ul> <li>Evaluates identity exposure relative to risk of compromise.</li> <li>Recommendations for strengthening MFA, access policies, and identity protection.</li> </ul> </li> <li>Ransomware Protection <ul> <li>Identifies attack vectors that can be exploited by ransomware.</li> <li>Implements recommendations for backup, network segmentation, and early detection.</li> </ul> </li> <li>SaaS Security Vulnerability Assessment <ul> <li>Monitors security configurations in cloud applications.</li> <li>Provides risk-based recommendations for data protection and access control.</li> </ul> </li> <li>Zero Trust <ul> <li>Analyzes current access policies and suggests improvements.</li> <li>Implements principles of least privilege and micro-segmentation.</li> </ul> </li> </ol> <p><img src="https://www.simsenblog.dk/images/posts/defender-security-exposure-management/SEM1-1024x651.png" alt="Exposure Management Initiatives page in Defender with the Zero Trust (Foundational) initiative highlighted"></p> <p><img src="https://www.simsenblog.dk/images/posts/defender-security-exposure-management/SEM2-1024x644.png" alt="Zero Trust (Foundational) initiative at 53% with its Security recommendations tab listing non-compliant actions"></p> <h2 id="what-does-this-mean-for-security-leaders">What does this mean for security leaders?</h2> <p>For security teams, this means a shift from reactive to proactive security.<br> Instead of constantly chasing the latest patches, teams can now focus on mitigating the biggest risks before they are exploited.</p> <p>One of the biggest benefits of Defender Security Exposure Management is that it aggregates security exposures across Microsoft’s diverse workloads.<br> This includes:</p> <ul> <li>Defender for Endpoint, Defender for Cloud Apps, and Defender for Cloud – covering endpoint protection, SaaS applications, and hybrid cloud environments.</li> <li>Defender for Identity and Entra ID – securing identities and access control from compromise.</li> <li>Defender for Office and SharePoint Online – protecting sensitive data in collaboration tools.</li> <li>Defender for IoT and Defender External Attack Surface Management – ​​monitoring external threats and unsecured IoT devices.</li> <li>Microsoft Information Protection – helping to classify and protect sensitive data.<br> But also external workloads such as: ServiceNow, Okta, Intune, Teams, Zoom, Slack, etc.</li> </ul> <h2 id="conclusion">Conclusion</h2> <p>Microsoft has quietly delivered one of the most powerful security tools in a long time. With Defender Security Exposure Management, organizations can finally get the insights they need to navigate the modern threat landscape.</p> <p>If your organization already uses Defender for Endpoint, check out this new feature—and start being more proactive about security today!</p> Simon Hartmann EriksenWindowsDefender XDRExposure managementASR Rules – anno 2023https://www.simsenblog.dk/2023/07/12/asr-rules-anno-2023/https://www.simsenblog.dk/?p=1716Attack Surface Reduction rules have become pivotal in my client projects. How to roll them out with Intune and Defender for Endpoint, from audit mode to block mode, with ready-made policy files.Wed, 12 Jul 2023 05:00:00 GMT<h2 id="introduction">Introduction</h2> <p>In my client management journey, Attack Surface Reduction (ASR) rules have become pivotal. These rules, central to Microsoft Defender, are designed to minimize the ‘opportunities’ for attackers to exploit our systems. Microsoft Defender for Endpoint further leverages these rules, providing enhanced alerting, reporting, and threat context, simplifying their management and enforcement. Adopting ASR rules is more than a reaction to threats; it’s a proactive approach to anticipate vulnerabilities. This shift has been key in fortifying our IT environment, strengthening our overall security posture against persistent cyber threats.</p> <h3 id="attack-surface-reduction-vs-attack-surface-reduction-rules">Attack Surface Reduction vs. Attack Surface Reduction Rules</h3> <p>ASR and ASR rules, while connected, refer to different aspects of cybersecurity. ASR, standing for Attack Surface Reduction, broadly denotes the set of built-in and cloud-enabled security features in Windows 10/11 that aim to decrease the potential entry points for malicious actors. This comprehensive strategy aligns with what’s known in the industry as a HIPS (Host Intrusion Prevention System) solution. On the other hand, within the framework of Microsoft Defender ATP, ASR is represented through ASR rules, which are…</p> <ul> <li>Attack surface reduction rules</li> <li>Hardware based isolation</li> <li>Application control</li> <li>Exploit protection</li> <li>Network protection</li> <li>Web protection</li> <li>Controlled folder access</li> <li>Network firewall</li> </ul> <hr> <h2 id="which-asr-rules-exist-in-intune">Which ASR rules exist in Intune?</h2> <ul> <li> <p><strong>Block Adobe Reader from creating child processes</strong></p> <ul> <li>Prevents Adobe Reader, a commonly exploited software, from initiating new processes which could be harmful.</li> </ul> </li> <li> <p><strong>Block execution of potentially obfuscated scripts</strong></p> <ul> <li>Blocks scripts that have been obfuscated to evade detection, a common practice in advanced attacks.</li> </ul> </li> <li> <p><strong>Block Win32 API calls from Office macros</strong></p> <ul> <li>Stops dangerous Win32 API calls originating from Office macros. Win32 API calls, while integral to some legitimate processes, can be hijacked for malicious activities.</li> </ul> </li> <li> <p><strong>Block credential stealing from the Windows local security authority subsystem (lsass.exe)</strong></p> <ul> <li>Prevents unauthorized access to lsass.exe, a key Windows component targeted for credential theft.</li> </ul> </li> <li> <p><strong>Block executable files from running unless they meet a prevalence, age, or trusted list criterion</strong></p> <ul> <li>This curtails execution of suspicious or unknown files, reducing the potential attack surface.</li> </ul> </li> <li> <p><strong>Block JavaScript or VBScript from launching downloaded executable content</strong></p> <ul> <li>Prevents JavaScript/VBScript from running downloaded executable files, a common technique used in attacks.</li> </ul> </li> <li> <p><strong>Block Office communication application from creating child processes</strong></p> <ul> <li>Restricts communication apps within Office from creating child processes, minimizing potential exploit avenues.</li> </ul> </li> <li> <p><strong>Block all Office applications from creating child processes</strong></p> <ul> <li>This rule stops Office applications from initiating new processes, reducing risks of malicious activities or unintended resource usage.</li> </ul> </li> <li> <p><strong>Block untrusted and unsigned processes that run from USB</strong></p> <ul> <li>Stops unauthorized or uncertified processes running from USB devices, protecting against potential malware attacks.</li> </ul> </li> <li> <p><strong>Block process creations originating from PSExec and WMI commands</strong></p> <ul> <li>Prevents potentially malicious process creations triggered by PSExec or WMI, tools often misused by attackers.</li> </ul> </li> <li> <p><strong>Block persistence through WMI event subscription</strong></p> <ul> <li>This rule stops attackers from using Windows Management Instrumentation for persistence, a common post-exploitation technique.</li> </ul> </li> <li> <p><strong>Block Office applications from creating executable content</strong></p> <ul> <li>Stops Office apps from generating executable content, reducing potential malware entry points.</li> </ul> </li> <li> <p><strong>Block Office applications from injecting code into other processes</strong></p> <ul> <li>Prevents Office apps from injecting code into other processes, a common technique used by malware.</li> </ul> </li> <li> <p><strong>Use advanced protection against ransomware</strong></p> <ul> <li>Applies enhanced security measures to defend against ransomware, a prevalent and disruptive type of malware.</li> </ul> </li> <li> <p><strong>Block executable content from email client and webmail</strong></p> <ul> <li>Stops executable content in email clients and webmail, protecting against email-based malware attacks.</li> </ul> </li> <li> <p><strong>Block abuse of exploited vulnerable signed drivers (Lastest ASR rule in GUI)</strong></p> <ul> <li>Stops misuse of exploited signed drivers, preventing another common attack avenue.</li> </ul> </li> </ul> <hr> <h2 id="where-to-start">Where to start?</h2> <p>Starting with ASR rules may seem daunting, but Microsoft Defender for Endpoint makes it considerably easier. To start, familiarize yourself with each rule and understand their impact on your environment. I recommend beginning with rules that have less likely disruptive effects. Turn on the rules in ‘audit mode’ first, which allows you to assess their impact without blocking anything. Microsoft Defender for Endpoint provides invaluable telemetry and alert data here. It logs every event where the rule would have been triggered, offering a clear view of potential disruptions. This makes it simpler to anticipate and manage any adjustments before switching to ‘block mode’, easing the entire process significantly.<br> Scroll down for more info about Defender for Endpoint insights.</p> <h3 id="asr-rules--easy-to-set">ASR Rules – Easy to set</h3> <p>The following rules are relatively straightforward to set. They typically have less impact on common workflows and cause fewer disruptions:</p> <ul> <li>Block Adobe Reader from creating child processes</li> <li>Block credential stealing from the Windows local security authority subsystem (lsass.exe)</li> <li>Block JavaScript or VBScript from launching downloaded executable content</li> <li>Block untrusted and unsigned processes that run from USB</li> <li>Block persistence through WMI event subscription</li> <li>Block Office applications from creating executable content</li> <li>Block executable content from email client and webmail</li> </ul> <h3 id="asr-rules--medium-to-set">ASR Rules – Medium to set</h3> <p>These rules require more careful consideration and testing. They may impact some common workflows and require more specific fine-tuning:</p> <ul> <li>Block execution of potentially obfuscated scripts</li> <li>Block Win32 API calls from Office macros</li> <li>Block Office communication application from creating child processes</li> <li>Block Office applications from injecting code into other processes</li> </ul> <h3 id="asr-rules--hard-to-set">ASR Rules – Hard to set</h3> <p>The following rules can be challenging to implement correctly. They require significant testing and may disrupt common workflows. It’s crucial to understand their potential impact before fully enabling them:</p> <ul> <li>Block executable files from running unless they meet a prevalence, age, or trusted list criterion</li> <li>Use advanced protection against ransomware</li> <li>Block process creations originating from PSExec and WMI commands <strong>(NO-GO if SCCM Agent is installed)</strong></li> <li>Block Office communication application from creating child processes</li> </ul> <hr> <h3 id="investigate-with-microsoft-defender-for-endpoint">Investigate with Microsoft Defender for Endpoint</h3> <p>Before you just set all “easy to set” policies in Block mode – it is always good to be in control and have done some investigation before enable policies. Here Microsoft Defender for Endpoint comes in handy.</p> <h3 id="so-how-can-i-help-you">So how can I help you?</h3> <p>Deploying ASR rules requires meticulous planning as “no rule is without exception”. Each rule can interact differently with your unique IT environment, potentially causing unexpected disruptions. Here I have tried something abnormal and maybe not recommended. But it gives you the possibility so assign each policy to a group.<br> It is of cause recommended to bundle the policies together!</p> <p>Prepare policies</p> <ol> <li>I have created 16 Attack Surface Reduction Rules policies in Intune – each policy for each ASR Rule.</li> </ol> <p><img src="https://www.simsenblog.dk/images/posts/asr-rules-anno-2023/ASR_Rules-1024x547.png" alt="Intune list of 16 Attack Surface Reduction policies, one per ASR rule, for Windows 10 and later"></p> <ol start="2"> <li>I have created 2 Sets – Above policies is exported to JSON files, ready to be imported to your tenant <ul> <li><a href="https://www.simsenblog.dk/Files/ASR_AuditMode.zip">Download all policies as in Audit mode</a></li> <li><a href="https://www.simsenblog.dk/Files/ASR_BlockMode.zip">Download all policies as in Block mode</a></li> </ul> </li> <li>Now import policies to your tenant with <a href="https://github.com/jseerden/IntuneBackupAndRestore">John Seerden’s Intune Backup &amp; Restore module</a> <ul> <li>Remember if you import both Audit and Block JSONs, policy name is the same.</li> </ul> </li> </ol> <h3 id="planning--with-defender-for-endpoint">Planning – with Defender for Endpoint</h3> <p>To have the best insights on how your endpoints will react on ASR rules – use this KQL(Kusto Query Language) script</p> <pre class="astro-code github-dark-dimmed" style="background-color:#22272e;color:#adbac7; overflow-x: auto;" tabindex="0" data-language="plaintext"><code><span class="line"><span>DeviceEvents </span></span> <span class="line"><span>| where Timestamp &gt; ago(30d) </span></span> <span class="line"><span>| where ActionType startswith "ASR"</span></span> <span class="line"><span>| summarize EventCount=count() by ActionType</span></span></code></pre> <p>It gives your a good overview on how the landscape is:</p> <p><img src="https://www.simsenblog.dk/images/posts/asr-rules-anno-2023/ASR_Overview.png" alt="Defender advanced hunting results counting ASR events by ActionType, such as AsrOfficeCommAppChildProcessBlocked"></p> <p>Then you can dive deeper into what each ASR Rule – to get computer names</p> <pre class="astro-code github-dark-dimmed" style="background-color:#22272e;color:#adbac7; overflow-x: auto;" tabindex="0" data-language="plaintext"><code><span class="line"><span>DeviceEvents </span></span> <span class="line"><span>| where (ActionType startswith "AsrOfficeMacro") </span></span> <span class="line"><span>| extend RuleId=extractjson("$Ruleid", AdditionalFields, typeof(string))</span></span> <span class="line"><span>| project DeviceName, FileName, FolderPath, ProcessCommandLine, InitiatingProcessFileName, InitiatingProcessCommandLine</span></span></code></pre> <h3 id="test-and-troubleshoot-asr-rules">Test and Troubleshoot ASR Rules</h3> <p>If you want to test or troubleshoot directly on a single PC – how the ASR tool could block a process. I can recommend this small <a href="https://github.com/hemaurer/MDATP_PoSh_Scripts/tree/master/ASR%20GUI">powershell GUI from hemaurer</a></p> <p><img src="https://www.simsenblog.dk/images/posts/asr-rules-anno-2023/ASR_Gui.png" alt="ASR Rules PoSh GUI listing each Attack Surface Reduction rule with Disabled, Audit, Enabled and Warn options"></p> <hr> <h3 id="disclaimer-">Disclaimer 🙂</h3> <p>Each IT environment is unique and an ‘easy’ ASR rule in one context could have a significant impact in another. Therefore, it’s vital to test each rule in your specific setting before fully implementing it. Use ‘audit mode’ and leverage the telemetry data from Microsoft Defender for Endpoint to assess potential disruptions. Always balance security measures with operational efficiency, and consult up-to-date Microsoft documentation or an IT professional for personalized guidance.</p> Simon Hartmann EriksenIntuneWindowsDefender for EndpointProactive Remediations – MS Defenderhttps://www.simsenblog.dk/2022/03/13/proactive-remediations-security-remediations/https://www.simsenblog.dk/?p=827Sometimes parts of Microsoft Defender stop running, even with Tamper Protection on. Proactive Remediation scripts that check every Defender component and start what has stopped.Sun, 13 Mar 2022 00:00:00 GMT<p>Microsoft Defender on each client is a high important tool as it both are an Antivirus tool – but also deliver info to Defender for Endpoint as a sensor.</p> <p>Microsoft developed Tamper Protection that should make sure evil software/process not should be able to disable Microsoft Defender.</p> <p>But we sometime see different components of Defender that is not running. Here Proactive Remediation scripts gets handy to make sure every day/week that Defender process is running and secure the client.</p> <p>We have scripts for:</p> <ul> <li>SCID-91: Enable Real Time Behavior Monitoring</li> <li>SCID-96: Enable Network Protection</li> <li>SCID-2012: Enable Real Time Protection</li> <li>SCID-2013: Enable PUA Protection(Potentially Unwanted Applications)</li> <li>SCID-2016: Enable Cloud Delivered Protection</li> </ul> <p><strong>Kudos to my good collegue <a href="https://windowstech.net/">Peter Jørgensen Madsen</a> for support on the scripts</strong>.</p> <p>All scripts is setup with following settings:</p> <p>Run this script using the logged-on credentials: <strong>No</strong><br> Enforce script signature check: <strong>No</strong><br> Run script in 64-bit PowerShell: <strong>Yes</strong></p> <hr> <p><strong>Enable Real Time Behavior Monitoring</strong></p> <p>Detection script</p> <pre class="astro-code github-dark-dimmed" style="background-color:#22272e;color:#adbac7; overflow-x: auto;" tabindex="0" data-language="powershell"><code><span class="line"><span style="color:#ADBAC7">$version </span><span style="color:#F47067">=</span><span style="color:#96D0FF"> 'C1'</span></span> <span class="line"><span style="color:#F47067">if</span><span style="color:#ADBAC7">((</span><span style="color:#6CB6FF">Get-MpComputerStatus</span><span style="color:#ADBAC7">).BehaviorMonitorEnabled </span><span style="color:#F47067">-eq</span><span style="color:#96D0FF"> "True"</span><span style="color:#ADBAC7">) {</span></span> <span class="line"><span style="color:#6CB6FF"> Write-Output</span><span style="color:#96D0FF"> "</span><span style="color:#ADBAC7">$version</span><span style="color:#96D0FF"> COMPLIANT"</span></span> <span class="line"><span style="color:#F47067"> exit</span><span style="color:#6CB6FF"> 0</span></span> <span class="line"><span style="color:#ADBAC7">} </span><span style="color:#F47067">else</span><span style="color:#ADBAC7"> {</span></span> <span class="line"><span style="color:#6CB6FF"> Write-Output</span><span style="color:#96D0FF"> "</span><span style="color:#ADBAC7">$version</span><span style="color:#96D0FF"> NON-COMPLIANT"</span></span> <span class="line"><span style="color:#F47067"> exit</span><span style="color:#6CB6FF"> 1</span></span> <span class="line"><span style="color:#ADBAC7">}</span></span></code></pre> <p>Remediation script</p> <pre class="astro-code github-dark-dimmed" style="background-color:#22272e;color:#adbac7; overflow-x: auto;" tabindex="0" data-language="powershell"><code><span class="line"><span style="color:#ADBAC7">$version </span><span style="color:#F47067">=</span><span style="color:#96D0FF"> 'R1'</span></span> <span class="line"><span style="color:#F47067">try</span><span style="color:#ADBAC7"> {</span></span> <span class="line"><span style="color:#6CB6FF"> Set-MpPreference</span><span style="color:#F47067"> -</span><span style="color:#ADBAC7">DisableBehaviorMonitoring </span><span style="color:#6CB6FF">$false</span></span> <span class="line"><span style="color:#6CB6FF"> Write-Output</span><span style="color:#96D0FF"> "</span><span style="color:#ADBAC7">$version</span><span style="color:#96D0FF"> Remediated"</span></span> <span class="line"><span style="color:#F47067"> exit</span><span style="color:#6CB6FF"> 0</span></span> <span class="line"><span style="color:#ADBAC7">}</span></span> <span class="line"><span style="color:#F47067">catch</span><span style="color:#ADBAC7"> {</span></span> <span class="line"><span style="color:#6CB6FF"> Write-Output</span><span style="color:#96D0FF"> "</span><span style="color:#ADBAC7">$version</span><span style="color:#96D0FF"> Failed"</span></span> <span class="line"><span style="color:#F47067"> exit</span><span style="color:#6CB6FF"> 1</span></span> <span class="line"><span style="color:#ADBAC7">}</span></span></code></pre> <hr> <p><strong>Enable Network Protection</strong></p> <p>Detection script</p> <pre class="astro-code github-dark-dimmed" style="background-color:#22272e;color:#adbac7; overflow-x: auto;" tabindex="0" data-language="powershell"><code><span class="line"><span style="color:#ADBAC7">$version </span><span style="color:#F47067">=</span><span style="color:#96D0FF"> 'C1'</span></span> <span class="line"><span style="color:#F47067">if</span><span style="color:#ADBAC7">((</span><span style="color:#6CB6FF">Get-MpPreference</span><span style="color:#ADBAC7">).EnableNetworkProtection </span><span style="color:#F47067">-eq</span><span style="color:#6CB6FF"> 1</span><span style="color:#ADBAC7">) {</span></span> <span class="line"><span style="color:#6CB6FF"> Write-Output</span><span style="color:#96D0FF"> "</span><span style="color:#ADBAC7">$version</span><span style="color:#96D0FF"> COMPLIANT"</span></span> <span class="line"><span style="color:#F47067"> exit</span><span style="color:#6CB6FF"> 0</span></span> <span class="line"><span style="color:#ADBAC7">} </span><span style="color:#F47067">else</span><span style="color:#ADBAC7"> {</span></span> <span class="line"><span style="color:#6CB6FF"> Write-Output</span><span style="color:#96D0FF"> "</span><span style="color:#ADBAC7">$version</span><span style="color:#96D0FF"> NON-COMPLIANT"</span></span> <span class="line"><span style="color:#F47067"> exit</span><span style="color:#6CB6FF"> 1</span></span> <span class="line"><span style="color:#ADBAC7">}</span></span></code></pre> <p>Remediation script</p> <pre class="astro-code github-dark-dimmed" style="background-color:#22272e;color:#adbac7; overflow-x: auto;" tabindex="0" data-language="powershell"><code><span class="line"><span style="color:#ADBAC7">$version </span><span style="color:#F47067">=</span><span style="color:#96D0FF"> 'R1'</span></span> <span class="line"><span style="color:#F47067">try</span><span style="color:#ADBAC7"> {</span></span> <span class="line"><span style="color:#6CB6FF"> Set-MpPreference</span><span style="color:#F47067"> -</span><span style="color:#ADBAC7">EnableNetworkProtection Enabled</span></span> <span class="line"><span style="color:#6CB6FF"> Write-Output</span><span style="color:#96D0FF"> "</span><span style="color:#ADBAC7">$version</span><span style="color:#96D0FF"> Remediated"</span></span> <span class="line"><span style="color:#F47067"> exit</span><span style="color:#6CB6FF"> 0</span></span> <span class="line"><span style="color:#ADBAC7">}</span></span> <span class="line"><span style="color:#F47067">catch</span><span style="color:#ADBAC7"> {</span></span> <span class="line"><span style="color:#6CB6FF"> Write-Output</span><span style="color:#96D0FF"> "</span><span style="color:#ADBAC7">$version</span><span style="color:#96D0FF"> Failed"</span></span> <span class="line"><span style="color:#F47067"> exit</span><span style="color:#6CB6FF"> 1</span></span> <span class="line"><span style="color:#ADBAC7">}</span></span></code></pre> <hr> <p><strong>Enable Real Time Protection</strong></p> <p>Detection script</p> <pre class="astro-code github-dark-dimmed" style="background-color:#22272e;color:#adbac7; overflow-x: auto;" tabindex="0" data-language="powershell"><code><span class="line"><span style="color:#ADBAC7">$version </span><span style="color:#F47067">=</span><span style="color:#96D0FF"> 'C1'</span></span> <span class="line"><span style="color:#F47067">if</span><span style="color:#ADBAC7">((</span><span style="color:#6CB6FF">Get-MpComputerStatus</span><span style="color:#ADBAC7">).RealTimeProtectionEnabled </span><span style="color:#F47067">-eq</span><span style="color:#96D0FF"> "True"</span><span style="color:#ADBAC7">) {</span></span> <span class="line"><span style="color:#6CB6FF"> Write-Output</span><span style="color:#96D0FF"> "</span><span style="color:#ADBAC7">$version</span><span style="color:#96D0FF"> COMPLIANT"</span></span> <span class="line"><span style="color:#F47067"> exit</span><span style="color:#6CB6FF"> 0</span></span> <span class="line"><span style="color:#ADBAC7">} </span><span style="color:#F47067">else</span><span style="color:#ADBAC7"> {</span></span> <span class="line"><span style="color:#6CB6FF"> Write-Output</span><span style="color:#96D0FF"> "</span><span style="color:#ADBAC7">$version</span><span style="color:#96D0FF"> NON-COMPLIANT"</span></span> <span class="line"><span style="color:#F47067"> exit</span><span style="color:#6CB6FF"> 1</span></span> <span class="line"><span style="color:#ADBAC7">}</span></span></code></pre> <p>Remediation script</p> <pre class="astro-code github-dark-dimmed" style="background-color:#22272e;color:#adbac7; overflow-x: auto;" tabindex="0" data-language="powershell"><code><span class="line"><span style="color:#ADBAC7">$version </span><span style="color:#F47067">=</span><span style="color:#96D0FF"> 'R1'</span></span> <span class="line"><span style="color:#F47067">try</span><span style="color:#ADBAC7"> {</span></span> <span class="line"><span style="color:#6CB6FF"> Set-MpPreference</span><span style="color:#F47067"> -</span><span style="color:#ADBAC7">DisableRealtimeMonitoring </span><span style="color:#6CB6FF">$false</span></span> <span class="line"><span style="color:#6CB6FF"> Write-Output</span><span style="color:#96D0FF"> "</span><span style="color:#ADBAC7">$version</span><span style="color:#96D0FF"> Remediated"</span></span> <span class="line"><span style="color:#F47067"> exit</span><span style="color:#6CB6FF"> 0</span></span> <span class="line"><span style="color:#ADBAC7">}</span></span> <span class="line"><span style="color:#F47067">catch</span><span style="color:#ADBAC7"> {</span></span> <span class="line"><span style="color:#6CB6FF"> Write-Output</span><span style="color:#96D0FF"> "</span><span style="color:#ADBAC7">$version</span><span style="color:#96D0FF"> Failed"</span></span> <span class="line"><span style="color:#F47067"> exit</span><span style="color:#6CB6FF"> 1</span></span> <span class="line"><span style="color:#ADBAC7">}</span></span></code></pre> <hr> <p><strong>Enable PUA Protection(Potentially Unwanted Applications)</strong></p> <p>Detection script</p> <pre class="astro-code github-dark-dimmed" style="background-color:#22272e;color:#adbac7; overflow-x: auto;" tabindex="0" data-language="powershell"><code><span class="line"><span style="color:#ADBAC7">$version </span><span style="color:#F47067">=</span><span style="color:#96D0FF"> 'C1'</span></span> <span class="line"><span style="color:#F47067">if</span><span style="color:#ADBAC7">((</span><span style="color:#6CB6FF">Get-MpPreference</span><span style="color:#ADBAC7">).PUAProtection </span><span style="color:#F47067">-eq</span><span style="color:#6CB6FF"> 1</span><span style="color:#ADBAC7">) {</span></span> <span class="line"><span style="color:#6CB6FF"> Write-Output</span><span style="color:#96D0FF"> "</span><span style="color:#ADBAC7">$version</span><span style="color:#96D0FF"> COMPLIANT"</span></span> <span class="line"><span style="color:#F47067"> exit</span><span style="color:#6CB6FF"> 0</span></span> <span class="line"><span style="color:#ADBAC7">} </span><span style="color:#F47067">else</span><span style="color:#ADBAC7"> {</span></span> <span class="line"><span style="color:#6CB6FF"> Write-Output</span><span style="color:#96D0FF"> "</span><span style="color:#ADBAC7">$version</span><span style="color:#96D0FF"> NON-COMPLIANT"</span></span> <span class="line"><span style="color:#F47067"> exit</span><span style="color:#6CB6FF"> 1</span></span> <span class="line"><span style="color:#ADBAC7">}</span></span></code></pre> <p>Remediation script</p> <pre class="astro-code github-dark-dimmed" style="background-color:#22272e;color:#adbac7; overflow-x: auto;" tabindex="0" data-language="powershell"><code><span class="line"><span style="color:#ADBAC7">$version </span><span style="color:#F47067">=</span><span style="color:#96D0FF"> 'R1'</span></span> <span class="line"><span style="color:#F47067">try</span><span style="color:#ADBAC7"> {</span></span> <span class="line"><span style="color:#6CB6FF"> Set-MpPreference</span><span style="color:#F47067"> -</span><span style="color:#ADBAC7">PUAProtection Enabled</span></span> <span class="line"><span style="color:#6CB6FF"> Write-Output</span><span style="color:#96D0FF"> "</span><span style="color:#ADBAC7">$version</span><span style="color:#96D0FF"> Remediated"</span></span> <span class="line"><span style="color:#F47067"> exit</span><span style="color:#6CB6FF"> 0</span></span> <span class="line"><span style="color:#ADBAC7">}</span></span> <span class="line"><span style="color:#F47067">catch</span><span style="color:#ADBAC7"> {</span></span> <span class="line"><span style="color:#6CB6FF"> Write-Output</span><span style="color:#96D0FF"> "</span><span style="color:#ADBAC7">$version</span><span style="color:#96D0FF"> Failed"</span></span> <span class="line"><span style="color:#F47067"> exit</span><span style="color:#6CB6FF"> 1</span></span> <span class="line"><span style="color:#ADBAC7">}</span></span></code></pre> <hr> <p><strong>Enable Cloud Delivered Protection</strong></p> <p>Detection script</p> <pre class="astro-code github-dark-dimmed" style="background-color:#22272e;color:#adbac7; overflow-x: auto;" tabindex="0" data-language="powershell"><code><span class="line"><span style="color:#ADBAC7">$version </span><span style="color:#F47067">=</span><span style="color:#96D0FF"> 'C1'</span></span> <span class="line"><span style="color:#F47067">if</span><span style="color:#ADBAC7">(((</span><span style="color:#6CB6FF">Get-MpPreference</span><span style="color:#ADBAC7">).MAPSReporting </span><span style="color:#F47067">-eq</span><span style="color:#6CB6FF"> 2</span><span style="color:#ADBAC7">) </span><span style="color:#F47067">-and</span><span style="color:#ADBAC7"> ((</span><span style="color:#6CB6FF">Get-MpPreference</span><span style="color:#ADBAC7">).SubmitSamplesConsent) </span><span style="color:#F47067">-eq</span><span style="color:#6CB6FF"> 3</span><span style="color:#ADBAC7">) {</span></span> <span class="line"><span style="color:#6CB6FF"> Write-Output</span><span style="color:#96D0FF"> "</span><span style="color:#ADBAC7">$version</span><span style="color:#96D0FF"> COMPLIANT"</span></span> <span class="line"><span style="color:#F47067"> exit</span><span style="color:#6CB6FF"> 0</span></span> <span class="line"><span style="color:#ADBAC7">} </span><span style="color:#F47067">else</span><span style="color:#ADBAC7"> {</span></span> <span class="line"><span style="color:#6CB6FF"> Write-Output</span><span style="color:#96D0FF"> "</span><span style="color:#ADBAC7">$version</span><span style="color:#96D0FF"> NON-COMPLIANT"</span></span> <span class="line"><span style="color:#F47067"> exit</span><span style="color:#6CB6FF"> 1</span></span> <span class="line"><span style="color:#ADBAC7">}</span></span></code></pre> <p>Remediation script</p> <pre class="astro-code github-dark-dimmed" style="background-color:#22272e;color:#adbac7; overflow-x: auto;" tabindex="0" data-language="powershell"><code><span class="line"><span style="color:#ADBAC7">$version </span><span style="color:#F47067">=</span><span style="color:#96D0FF"> 'R1'</span></span> <span class="line"><span style="color:#F47067">try</span><span style="color:#ADBAC7"> {</span></span> <span class="line"><span style="color:#6CB6FF"> Set-MpPreference</span><span style="color:#F47067"> -</span><span style="color:#ADBAC7">MAPSReporting Advanced</span></span> <span class="line"><span style="color:#6CB6FF"> Set-MpPreference</span><span style="color:#F47067"> -</span><span style="color:#ADBAC7">SubmitSamplesConsent SendAllSamples</span></span> <span class="line"><span style="color:#6CB6FF"> Write-Output</span><span style="color:#96D0FF"> "</span><span style="color:#ADBAC7">$version</span><span style="color:#96D0FF"> Remediated"</span></span> <span class="line"><span style="color:#F47067"> exit</span><span style="color:#6CB6FF"> 0</span></span> <span class="line"><span style="color:#ADBAC7">}</span></span> <span class="line"><span style="color:#F47067">catch</span><span style="color:#ADBAC7"> {</span></span> <span class="line"><span style="color:#6CB6FF"> Write-Output</span><span style="color:#96D0FF"> "</span><span style="color:#ADBAC7">$version</span><span style="color:#96D0FF"> Failed"</span></span> <span class="line"><span style="color:#F47067"> exit</span><span style="color:#6CB6FF"> 1</span></span> <span class="line"><span style="color:#ADBAC7">}</span></span></code></pre> <hr> Simon Hartmann EriksenIntuneWindowsDefender for EndpointPowerShellUse MDfE to hunt for PrintNightmarehttps://www.simsenblog.dk/2021/07/12/use-mdfe-to-search-for-cve-2021-34527-printnightmare/https://www.simsenblog.dk/?p=527Track PrintNightmare (CVE-2021-34527) patching with Advanced Hunting in Defender for Endpoint: queries that find which Windows 10 devices are patched and which are still vulnerable.Mon, 12 Jul 2021 03:00:00 GMT<p>We have the last week tried to patch endpoints for the PrintNightmare Vulnerability(CVE-2021-34527) – and Microsoft still have an open gab for this.</p> <p>But to follow the patching – here Microsoft Defender for Endpoint gets handy. Specially with the <a href="https://security.microsoft.com/advanced-hunting">Advanced Hunting</a>.</p> <p>Query to search for Windows 10 devices that is patched:</p> <pre class="astro-code github-dark-dimmed" style="background-color:#22272e;color:#adbac7; overflow-x: auto;" tabindex="0" data-language="plaintext"><code><span class="line"><span>DeviceInfo</span></span> <span class="line"><span>| where MachineGroup == "INSERT GROUP NAME"</span></span> <span class="line"><span>| join kind = inner DeviceEvents on DeviceId</span></span> <span class="line"><span>| where FolderPath contains "Windows10.0-KB5004945"</span></span> <span class="line"><span>or FolderPath contains "Windows10.0-KB5004946"</span></span> <span class="line"><span>or FolderPath contains "Windows10.0-KB5004947"</span></span> <span class="line"><span>or FolderPath contains "Windows10.0-KB5004948"</span></span> <span class="line"><span>or FolderPath contains "Windows10.0-KB5004950"</span></span> <span class="line"><span>| distinct DeviceName</span></span></code></pre> <p>Query to search for Windows 10 devices that still have the vulnerability</p> <pre class="astro-code github-dark-dimmed" style="background-color:#22272e;color:#adbac7; overflow-x: auto;" tabindex="0" data-language="plaintext"><code><span class="line"><span>DeviceInfo</span></span> <span class="line"><span>| where MachineGroup == "INSERT GROUP NAME"</span></span> <span class="line"><span>| join kind = inner DeviceTvmSoftwareVulnerabilities on DeviceId</span></span> <span class="line"><span>| where OSPlatform == "Windows10"</span></span> <span class="line"><span>| where CveId == "CVE-2021-34527"</span></span> <span class="line"><span>| summarize CVE_Total = count(), makeset(CveId) by DeviceName, OSPlatform</span></span> <span class="line"><span>| sort by CVE_Total asc</span></span></code></pre> Simon Hartmann EriksenWindowsDefender for Endpoint