How to Enable PUA Protection in MS Defender Using PowerShell

In the cybersecurity landscape, the continuous evolution of threats has made proactive measures a necessity for any organization. One such measure is PUA (Potentially Unwanted Application) protection, a feature in Microsoft Defender that helps prevent unwanted software installations. By ensuring that systems are safeguarded against these potential threats, IT professionals and MSPs (Managed Service Providers) can significantly enhance their security posture.

Background

PUA protection, as part of Microsoft Defender, is a feature that detects and blocks applications that aren’t necessarily malicious but may be unwanted because of their behavior or impact on a system. This script’s importance cannot be understated. IT professionals and MSPs need tools to ensure their systems’ security, and enabling PUA protection is one of those critical tools. With an increasing number of software being distributed online, the risk of inadvertently downloading and installing unwanted applications is higher than ever.

The Script

<#
.SYNOPSIS
    Enables PUA protection in MS Defender
.DESCRIPTION
    Enables PUA protection in MS Defender
.EXAMPLE
    No parameters needed.
    Enables PUA protection in MS Defender
.OUTPUTS
    None
.NOTES
    Minimum OS Architecture Supported: Windows 10, Windows Server 2016
    Release Notes:
    Initial Release
By using this script, you indicate your acceptance of the following legal terms as well as our Terms of Use at https://www.ninjaone.com/terms-of-use.
    Ownership Rights: NinjaOne owns and will continue to own all right, title, and interest in and to the script (including the copyright). NinjaOne is giving you a limited license to use the script in accordance with these legal terms. 
    Use Limitation: You may only use the script for your legitimate personal or internal business purposes, and you may not share the script with another party. 
    Republication Prohibition: Under no circumstances are you permitted to re-publish the script in any script library or website belonging to or under the control of any other software provider. 
    Warranty Disclaimer: The script is provided “as is” and “as available”, without warranty of any kind. NinjaOne makes no promise or guarantee that the script will be free from defects or that it will meet your specific needs or expectations. 
    Assumption of Risk: Your use of the script is at your own risk. You acknowledge that there are certain inherent risks in using the script, and you understand and assume each of those risks. 
    Waiver and Release: You will not hold NinjaOne responsible for any adverse or unintended consequences resulting from your use of the script, and you waive any legal or equitable rights or remedies you may have against NinjaOne relating to your use of the script. 
    EULA: If you are a NinjaOne customer, your use of the script is subject to the End User License Agreement applicable to you (EULA).
#>
[CmdletBinding()]
param ()

begin {
    function Test-IsElevated {
        $id = [System.Security.Principal.WindowsIdentity]::GetCurrent()
        $p = New-Object System.Security.Principal.WindowsPrincipal($id)
        $p.IsInRole([System.Security.Principal.WindowsBuiltInRole]::Administrator)
    }
}
process {
    if (-not (Test-IsElevated)) {
        Write-Error -Message "Access Denied. Please run with Administrator privileges."
        exit 1
    }
    if ($(Get-Command -Name "Set-MpPreference").Name -like "Set-MpPreference") {
        if ($(Get-MpPreference | Select-Object PUAProtection -ExpandProperty PUAProtection) -eq 0) {
            try {
                Set-MpPreference -PUAProtection Enabled -ErrorAction Stop
            }
            catch {
                Write-Error $_
                exit 1
            }
            Write-Host "PUAProtection enabled."
        }
        else {
            Write-Host "PUAProtection already enabled."
        }
    }
    else {
        Write-Error "The module ConfigDefender was not found. Is MS Defender installed?"
    }
    exit 0
}
end {}

 

Access 300+ scripts in the NinjaOne Dojo

Get Access

Potential Use Cases

Imagine an IT professional, Jane, at a medium-sized company. The company has recently faced issues with employees downloading software that, while not overtly malicious, has impacted system performance and potentially compromised data privacy. Jane can deploy this script across all company systems, ensuring that PUA protection is enabled, reducing the risk of such installations in the future.

Alternative Approach

Manually enabling PUA protection involves navigating through Microsoft Defender’s settings or Group Policy, which can be time-consuming when dealing with multiple systems. This script provides an automated and faster solution. Moreover, this script can be deployed across multiple systems simultaneously, whereas manual methods would need to be repeated for each machine.

FAQs

  • Is administrator privilege always necessary?
    Yes, to change system-wide settings, you need administrator privileges.
  • What if Microsoft Defender isn’t installed?
    The script will throw an error message guiding the user about the missing module.

Implications

By enabling PUA protection, systems are shielded against a broader range of threats. While PUA isn’t always harmful, they can degrade system performance or present privacy concerns. The script ensures an added layer of IT security, making sure potentially harmful applications are caught before they can be installed.

Recommendations

  • Always run the script with administrator privileges.
  • Ensure Microsoft Defender is installed and updated before running the script.
  • Regularly review and update scripts to accommodate any changes in software behavior or updates.

Final Thoughts

In the ever-evolving world of IT security, tools like NinjaOne are instrumental. NinjaOne’s integrated platform could seamlessly incorporate such scripts, allowing IT professionals to manage and deploy them effortlessly. By automating processes like enabling PUA protection, organizations can ensure they’re always one step ahead in their cybersecurity efforts.

Next Steps

Building an efficient and effective IT team requires a centralized solution that acts as your core service deliver tool. NinjaOne enables IT teams to monitor, manage, secure, and support all their devices, wherever they are, without the need for complex on-premises infrastructure.

Learn more about NinjaOne Remote Script Deployment, check out a live tour, or start your free trial of the NinjaOne platform.

Categories:

You might also like

×

See NinjaOne in action!

By submitting this form, I accept NinjaOne's privacy policy.

NinjaOne Terms & Conditions

By clicking the “I Accept” button below, you indicate your acceptance of the following legal terms as well as our Terms of Use:

  • Ownership Rights: NinjaOne owns and will continue to own all right, title, and interest in and to the script (including the copyright). NinjaOne is giving you a limited license to use the script in accordance with these legal terms.
  • Use Limitation: You may only use the script for your legitimate personal or internal business purposes, and you may not share the script with another party.
  • Republication Prohibition: Under no circumstances are you permitted to re-publish the script in any script library belonging to or under the control of any other software provider.
  • Warranty Disclaimer: The script is provided “as is” and “as available”, without warranty of any kind. NinjaOne makes no promise or guarantee that the script will be free from defects or that it will meet your specific needs or expectations.
  • Assumption of Risk: Your use of the script is at your own risk. You acknowledge that there are certain inherent risks in using the script, and you understand and assume each of those risks.
  • Waiver and Release: You will not hold NinjaOne responsible for any adverse or unintended consequences resulting from your use of the script, and you waive any legal or equitable rights or remedies you may have against NinjaOne relating to your use of the script.
  • EULA: If you are a NinjaOne customer, your use of the script is subject to the End User License Agreement applicable to you (EULA).