Set MpPreference - PowerShell


Set-MpPreference configures settings for Microsoft Defender Antivirus. It allows users to adjust various parameters, such as scan schedules, scan types, and real-time protection settings. This command is essential for customizing and managing the behavior of Microsoft Defender Antivirus to suit specific needs.


Set-MpPreference [[-Name] <String>] [[-Value] <Object>] [-Asynchronous] [-InputObject <Object>] [-PassThru]


| Option/Flag | Description | Default Value |
| -Name | Specifies the name of the preference setting to configure. A list of available preferences can be obtained using the Get-MpPreference command. | – |
| -Value | Sets the value of the specified preference. The value type varies depending on the preference being configured. | – |
| -Asynchronous | Runs the command asynchronously, allowing other commands to execute while this command is running. | False |
| -InputObject | Accepts a Microsoft.Windows.Mp.MpPreference object as input, allowing you to set multiple preferences at once. | – |
| -PassThru | Returns the Microsoft.Windows.Mp.MpPreference object after it has been modified. | False |


Example 1: Enable real-time protection

Set-MpPreference -Name RealTimeProtection -Value 1

Example 2: Schedule a daily quick scan at 3:00 AM

Set-MpPreference -Name ScheduledQuickScanTime -Value "03:00"
Set-MpPreference -Name ScheduledQuickScanDay -Value "Daily"

Example 3: Set custom scan types

Set-MpPreference -Name CustomScanTypes -Value "FullScan,QuickScan,DefinitionUpdate"

Common Issues

  • Error: The preference setting is not recognized. Ensure that you have specified the correct -Name for the preference you want to configure.
  • Error: The value is not valid for the specified preference. Check the documentation for the specific preference to determine the valid value types.
  • Error: The command is not working as expected. Restart your computer and try again.


Set-MpPreference can be integrated with other PowerShell commands for advanced tasks. Here are a few examples:**

  • Use Get-MpPreference to retrieve the current values of all preference settings.
  • Combine Set-MpPreference with Invoke-WebRequest to download and install the latest definition updates.
  • Use Set-MpPreference with Start-Job to schedule automated scan and update tasks.
  • Get-MpPreference
  • Update-MpSignature
  • Start-MpScan