Blog Post

Microsoft Defender for Endpoint Blog
8 MIN READ

Configuring Microsoft Defender Antivirus for non-persistent VDI machines

JesseEsquivel's avatar
JesseEsquivel
Icon for Microsoft rankMicrosoft
Jun 25, 2020

Updated 3/23/2023 to focus on the shared security intelligence feature for VDI.

 

Virtual Desktop Infrastructure (VDI) brings an interesting dynamic when tuning the platform. The delicate balance of performance and usability are key to the user experience and can require fine tuning of all sorts of items in Windows. Antivirus can also benefit from VDI specific configurations and tuning. Among all other settings, it's crucial to ensure antivirus protection on the device is configured optimally.

 

Microsoft Defender Antivirus is a critical and built-in component in the Microsoft endpoint protection platform. this article includes guidance and recommendations for Microsoft Defender Antivirus on non-persistent VDI machines. This article covers optimizations, best practices, and recommended settings for configuring Microsoft Defender AV in a non-persistent VDI environment.

 

In my first VDI post I described how the non-persistent VDI deployment type works and interacts in a VDI master/child relationship. When non-persistent VDI machines are onboarded to Microsoft Defender for Endpoint at first boot, you also want to provide Microsoft Defender AV protection for non-persistent VDI machines at first boot.

 

To ensure you have protection for VDI machines at first boot, follow these recommendations:

 

  1. Make sure that Microsoft Defender Antivirus security intelligence updates (which contain the Microsoft Defender Antivirus updates) are available for the VDI machines to consume
  2. Configure bare minimum settings that tell the VDI machines where to go to get the updates
  3. Apply any optimizations and other settings to the VDI machines at first boot. Some security policy settings can be set via the local security policy editor

Part 1: Security intelligence updates download and availability

 

As described in the first VDI post, non-persistent VDI machines generally don’t use a configuration management solution like Microsoft Intune because they don’t persist their state (all changes to the VDI machine are lost at logoff, reboot, or shutdown). This means the usual recommended delivery mechanism for security intelligence updates can’t be used. Fortunately, you have options to configure how the updates are delivered to Windows.

 

There are two different ways a Windows device can consume security intelligence from a UNC file share.

The first method is to use the signature fallback order to consume the mpam-fe.exe update from the UNC share. This method requires the following folder path in the UNC share (architecture\mpam-fe.exe). For example: \\fileserver.fqdn\mdatp$\wdav-update\x64 This method is not optimized for non-persistent VDI and is intended to be a fallback/additional method for Windows clients to get the update. References are here:

 

 

Note: As this method is NOT optimized for non-persistent VDI, it will not be the focus of this article.

 

The second method involves using the Define security intelligence location for VDI clients setting.  This setting offloads the extraction of the security intelligence update onto a host machine, which saves CPU, disk, and memory resources on the non-persistent VDI machines.

 

Note: This method configures non-persistent VDI machines to load pre-extracted security intelligence directly from the UNC share. When this setting is configured it disables all other forms of security intelligence update.

 

The settings can be accessed in the local group policy editor at the following path:

 

Computer Configuration\Administrative Templates\Windows Components\Microsoft Defender Antivirus

 

It’s important to understand how to get the security intelligence packages to the file share in question. This means that a single server or machine must fetch the updates on behalf of the VMs at an interval and place them in the file share for consumption.

 

First, create an SMB/CIFS file share. In the following example, a file share is created with the following share permissions, and an NTFS permission is added for Authenticated Users:Read:

 

 

For this example, the file share is:

\\fileserver.fqdn\mdatp$\wdav-update

 

Ensure that the VDI devices have read access via the SYSTEM context to the share in order to fetch the updates. Also ensure that the server or machine that is fetching the updates has read/write access to it so that it can write the security intelligence updates into the wdav-update folder. General guidance on how to download and unpack the updates with a PowerShell script and run it as a scheduled task are here.

In addition, there are some other things to consider for this operation and tie them all together. I’ve written a sample PowerShell script (based on the guidance) that can be run at an interval as a scheduled task. The script takes the following steps:

 

  1. Fetch x64 security intelligence update and download to local folder that is named as a unique GUID, such as the following:

         C:\Windows\wdav-update\{00000000-0000-0000-0000-yMMddHHmmss}\mpam-fe.exe

 

  1. Extract the x64 security intelligence update:

         mpam-fe.exe /X

 

  1. The contents of the folder are now the extracted package:        

     

  2. Copy the entire C:\Windows\wdav-update\{00000000-0000-0000-0000-yMMddHHmmss}\ folder to the file share at the following path: 

    \\fileserver.fqdn\mdatp$\wdav-update

  3. Remove folders older than 7 days (configurable) in the following paths:

    C:\Windows\wdav-update\
    \\fileserver.fqdn\mdatp$\wdav-update\

  4. Log all actions to the Application event log on the system

 

That’s a quick breakdown of what the sample does and it’s available here. It takes care of fetching the security intelligence updates, unpacking them, and copying them to the file share that the VDI machines will grab them from. To recap, at this point, the VDI machines are configured to go to the file share for the updates, and a single machine gets the updates to the file share.

 

Part 2: First boot Microsoft Defender Antivirus settings

 

When the file share is all set up and populated with the updates, you can configure a few things on the VDI master. Remember to configure these settings in the VDI master so that the child VDI machines will have the settings at first boot. The settings can be viewed in the local security policy editor here:

 

Computer Configuration\Administrative Templates\Windows Components\Microsoft Defender Antivirus

 

Note: Depending on the release of Windows the ADMX template can vary and the path will either include “Windows Defender Antivirus” or “Microsoft Defender Antivirus” in the latest templates.

 

In this tree of the editor the setting to configure is below.

 

  • Define security intelligence location for VDI clients  This setting offloads the extraction of the security intelligence update onto a host machine (the server that is running the PowerShell job to fetch the updates and place them in the share in this case), which saves CPU, disk, and memory resources on the non-persistent VDI machines.

Note: This setting requires a reboot of the VDI machine for it to take effect. This is why it is critical to include it as a first boot policy. All other signature update mechanisms as well as manual signature updates via mpcmdrun -signatureupdate or via the Update-MpSignature PowerShell cmdlet are disabled when using this setting. Here is a snip from the MPLog (located in C:\ProgramData\Microsoft\Windows Defender\Support) after enabling the setting:

 

 

VDI machines expect the extracted security intelligence update to be available at the following location:

 
\\fileserver.fqdn\mdatp$\wdav-update\{GUID}

 

When a VDI machine is using the define security intelligence location for VDI clients setting , in the MPLog (located in C:\ProgramData\Microsoft\Windows Defender\Support) you’ll see it parse the GUID folder in the file share looking for the security intelligence update:

 

 

If you see an access denied message when trying to update security intelligence in the operational log, check the share and NTFS permissions that were mentioned above.

 

 

The biggest thing to remember is what folder machines will go to for the security intelligence update when the Define security intelligence location for VDI clients setting is enabled.

 

For VDI systems with the Define security intelligence location for VDI clients setting enabled, they will look at the following path for updates:

 

\\fileserver.fqdn\mdatp$\wdav-update\{00000000-0000-0000-0000-yMMddHHmmss}

 

Part 3: Microsoft Defender Antivirus settings

 

One of the most important settings to consider is the Turn off Microsoft Defender Antivirus setting. We strongly recommend that you do NOT change this setting to Enabled as doing so will disable Microsoft Defender Antivirus. Even if you are using a third-party antivirus solution, Microsoft still recommends leaving this setting at its default setting of Not Configured.

 

The reason for this is that when a third-party antivirus registers itself with the Microsoft Defender Security Center in Windows Microsoft Defender Antivirus will automatically go into passive mode if it is onboarded into Defender for Endpoint. When Microsoft Defender Antivirus is in passive mode, Microsoft Defender for Endpoint still uses the AV engine to perform certain functions, some of which are in the Microsoft 365 Defender portal (https://security.microsoft.com). A few examples are:

 

  • Trigger an antivirus scan
  • Detection information
  • Security intelligence updates
  • Endpoint detection and response (EDR) in block mode

More information on Microsoft Defender Antivirus in passive mode can be found here. The rest of the settings are pulled from the Microsoft Defender Antivirus VDI guidance, but let’s go over the optimal settings for when you are using the Define security intelligence location for VDI clients setting.

 

  • Specify the scan type to use for a scheduled scan  This setting allows you to specify the type of scan to be used, and for VDI machines the Quick Scan (default) value is recommended.
  • Randomize scheduled task times  This setting ensures that scheduled scans are randomized at a four-hour interval and for VDI machines the Enabled or Not Configured (Default) value is recommended.
  • Define the number of days before Antivirus security intelligence is considered out of date  This setting does just that. You need to pick the number of days after which you consider an endpoint’s antivirus to be out of date. If a client surpasses the number of days, certain actions, such as failing back to an alternate source and displaying warning icons in the user interface are triggered. This is another one you need to tune for your environment. Plan on tuning this in accordance with the number of days of security intelligence packages that you are keeping on the file share.

For this example, I’m removing security intelligence package downloads (via the PowerShell sample script) from the file share that are older than 7 days, so I’ve also set this setting to 7 (since I only keep 7 days’ worth anyway).

 

  • Define the number of days before virus security intelligence is considered out of date  This is the same setting as above, treat it and tune the same way. Typically, this will be the same setting as the setting above and in this example, I’ve also set this to “7.”

Tying it all together

 

In summary, we’ve configured a scheduled task on a designated machine to fetch, extract, and place the uncompressed security intelligence packages in a file share. Non-persistent VDI machines are pointed to this share in order to fetch the updates. We also went over a few of the bare minimum settings to provide first boot protection for non-persistent VDI machines, as well as a few other settings that should be optimized for them. Automation is definitely the glue here that keeps all of this together.

 

From the VDI master perspective, fold all of these settings together either in the registry or by using a local group policy object.

 

Tools like the Microsoft Deployment Toolkit (MDT) allow for automation of applying these settings to the VDI master, and as mentioned in my last post I’ve also integrated these first boot Microsoft Defender Antivirus settings into a sample script that’s used to stage the Microsoft Defender ATP onboarding script on your VDI master during an MDT task sequence.

 

Hopefully, this helps you test, optimize, and deploy Microsoft Defender Antivirus on your non-persistent VDI pools! Let us know what you think by leaving a comment below.

 

Jesse Esquivel, Product Manager

Microsoft Defender for Endpoint

Updated Mar 23, 2023
Version 23.0

48 Comments

  • Daniel-San's avatar
    Daniel-San
    Copper Contributor

    baker999855How does your setup looks alike (e.g. NTFS Security Permissions?)

    I am trying getting to work it for weeks - and I am still failing.

     

    What does work on my lab:

    • Downloading the Windows Defender Updates mpam-fe.exe from the x64 shared folder and extratcting it on all VDI's - that's not my golden target. I want to save the CPU performance for extracting the mpam-fe.exe on every VDI

    What dows not work on my lab:

    • Downloading the extracted Security Intelligence Update files from the mpam-fe.exe in the GUID shared folder and self deploying it without any extracting task on all VDI's - the well known permission error is appearing in Windows Defender log file and Eventlog

    I am curious how you have got it to work.

     

    Thank you in advande

    Daniel

  • Mark1874's avatar
    Mark1874
    Copper Contributor

    Hi,

    Really good article, thank you.

     

    My question relates to reporting on Defender antivirus compliance.

    Microsoft's documentation states this is usually achieved through SCCM, Intune or MEM.  However traitionaly non-persistent VDI desktops are not managed by these systems due to their starless nature.

    What is the best way to report antivirus compliance for the non-persistent desktops?

  • baker999855's avatar
    baker999855
    Copper Contributor

    For anyone else experiencing issues with this - we resolved it by doing the following:

    1/ Delete the local group policy cache %windir%\System32\GroupPolicy (hidden) User and Machine folder.

    2/ Configure the settings mentioned in the above blog in local policy only, reboot.

    3/ Configure the other settings (scan times, quarantine actions etc) in domain group policy.

    4/Set the 'Define order of sources..' as 'Fileshares' only, no other values.

     

    Thanks

  • Hi Baker - the best course of action to receive help on this is to open a Microsoft support case.

  • baker999855's avatar
    baker999855
    Copper Contributor

    Thanks for this - apologies I can see you covered that error in the blog (I didn't have the issue the first time I read it..!).

     

    We have (to this point) been configuring the settings for VDI using group policy , not local group policy. I have since rectified this, but noticed a few issues:

    1/ the registry in our master image is missing the 'UpdateOnStartUp dword=1' key , despite enabling local group policy setting 'Check for intelligence on startup'

     

    2/ I've followed the guide above closely and have both settings configured in local policy. However, the VM's still fail to update from the file share. The share permissions are below. The VM's can contact the share and 

     

    However, even with those both those settings defined it still doesn't work consistently.  We have 'Define file shares for downloading sec intelligence updates' set to: \\share\wdav-update.  The GPO informational help for that settings suggests multiple sources should be entered in the format {"\\uncshare1 | \\uncshare2"} - we only have 1 share, so I'm assuming that because we only have 1 source, then entering the value without {".."} characters is still valid? e.g.  \\share\wdav-update

    As you can see, we have both aforementioned policies configured locally, we also have 'Check for intelligence updates on startup' and 'Check for latest virus and spyware intell on startup' too. Strangely, when setting these latter 2 policies on the local policy editor, no registry key is created under HKLM\Software\policies\MS\Windows Defender\Updates..\UpdateOnStartUp dword=1  - but if it's set via group policy on the domain, then those registrry keys are created . I added the key manually on our image, rebooted, but the VM's still don't update. 

     

    This is the local group policy settings:

    Is this valid as a value, or must we also set the other possible values in order of preference i.e. FileShares|MMPC|UpdateServer etc, and if so, should the values be entered in the same formatting as the help example with a carriage return between each pipe e.g. FileShares | MMPC, or Fileshares|MMPC ?

     

    At this point it's really not clear why this is failing - we've set the baseline policies correctly, and I've even tested it functionally by using psexec to launch cmd prompt as SYSTEM context, browse to the share, and run the mpam-fe.exe file - it installs and updates the VM in moments. Any pointers on what might be causing this misconfiguration? We actually had this working (albeit erratically) by using only group policy, no local policy - some VM's would update, others would not, we have no other AV installed on our image (fresh build). I would also expect our master image (logged in as local admin) to update itself , there are no 'ACCESS DENIED' errors in the event log.

     

    This is how the registry looks on the VM's . When they boot they show up to date. checking the mplog file , it shows the share is being checked, but then it refers to a local definition pack instead of downloading the latest from the share? Note, if I then manually update the definition pack to the latest, the GUI still declares it's up to date, and the engine revision changes accordingly - the VM thinks it's up to date, but it's not...

    Sorry for lengthy email, but I'm amazed how convoluted it is to get this working, do you have any ideas/pointers for troubleshooting this please?

     

     

     

     

     

     

     

     

  • Hi Baker - Check that you have both of these settings enabled:

    Define file shares for downloading security intelligence updates

    Define security intelligence location for VDI clients

  • Hi Bert,

     

    1) Thanks for pointing this out, the other article should say 1703 as the change was backported.  We'll get the article updated.

    2) If you're running Windows update on your master image (before you deploy your pools) then you should have the latest SIU installed already : )  You can also choose to install the latest security intelligence update manually as part of your master image if you like.
        Microsoft Defender update for Windows operating system installation images

    3) When the client checks for an update is controlled by a few settings (or default settings), have a look under Computer Configuration/Administrative Templates/Windows Components/Microsoft (or Windows) Defender Antivirus/Security Intelligence Updates

    Best,

     

    Jesse

     

  • Bert_MOD's avatar
    Bert_MOD
    Copper Contributor

    Hello Jesse,

    Question 1)
    In your article you mention: Note: Defining a security intelligence location only works https://docs.microsoft.com/en-us/windows/security/threat-protection/windows-defender-antivirus/deployment-vdi-windows-defender-antivirus#set-up-a-dedicated-vdi-file-share.
    If I follow the link, the article begins with: In Windows 10, version 1903, we introduced the shared security intelligence feature.

    So little confusion here is it from 1703 or 1903. I configured it here with 1809 and it seems to work.

    Question 2)

    I also have an other question. If the fileshare isn't available the VDI clients will boot without definitions.
    Is it possible to start with a local definition set (build in the masterimage, this image is mostly build once in a month with new security patches.) 
    So the image have at least a defnition set to start (of course it get outdated) and as soon as it start it trggers a update and update to the newest definiton set. In case the DFS/Fileshare is not available there is at least an definiton set loaded, there is some protection?

    question 3)
    We did some testing and see that immediatly after placing a new definition set on the file share als VDI client get updated in a few minutes
    How do the clients know so fast that a new definition set is placed on the wdv-update share?

    regards
    Bert