Onboard non-persistent virtual desktop infrastructure (VDI) devices in Microsoft 365 Defender
Virtual desktop infrastructure (VDI) is an IT infrastructure concept that lets end users access enterprise virtual desktops instances from almost any device (such as your personal computer, smartphone, or tablet), eliminating the need for organization to provide users with physical machines. Using VDI devices reduce cost as IT departments are no longer responsible for managing, repairing, and replacing physical endpoints. Authorized users can access the same company servers, files, apps, and services from any approved device through a secure desktop client or browser.
Like any other system in an IT environment, these too should have an Endpoint Detection and Response (EDR) and Antivirus solution to protect against advanced threats and attacks.
- Microsoft Defender for Endpoint Plan 2
- Microsoft 365 Defender
- Virtual desktop infrastructure (VDI) devices
- Windows 10, Windows 11, Windows Server 2019, Windows Server 2022, Windows Server 2008R2/2012R2/2016
Want to experience Defender for Endpoint? Sign up for a free trial.
Persistent VDI's - Onboarding a persistent VDI machine into Microsoft Defender for Endpoint is handled the same way you would onboard a physical machine, such as a desktop or laptop. Group policy, Microsoft Endpoint Manager, and other methods can be used to onboard a persistent machine. In the Microsoft 365 Defender portal, (https://security.microsoft.com) under onboarding, select your preferred onboarding method, and follow the instructions for that type.
Onboarding non-persistent virtual desktop infrastructure (VDI) devices
Defender for Endpoint supports non-persistent VDI session onboarding.
There might be associated challenges when onboarding VDI instances. The following are typical challenges for this scenario:
- Instant early onboarding of a short-lived session, which must be onboarded to Defender for Endpoint prior to the actual provisioning.
- The device name is typically reused for new sessions.
In a VDI environment, VDI instances can have short lifespans. VDI devices can appear in Defender for Endpoint portal as either:
Single portal entry for each VDI instance. If the VDI instance was already onboarded to Microsoft Defender for Endpoint and at some point deleted then recreated with the same host name, a new object representing this VDI instance will NOT be created in the portal.
In this case, the same device name must be configured when the session is created, for example using an unattended answer file.
Multiple entries for each device - one for each VDI instance.
The following steps will guide you through onboarding VDI devices and will highlight steps for single and multiple entries.
For environments where there are low resource configurations, the VDI boot procedure might slow the Defender for Endpoint sensor onboarding.
For Windows 10, or Windows 11, or Windows Server 2012 R2 and later
Windows Server 2016 and Windows Server 2012 R2 will need to be prepared by applying the installation package first using the instructions in Onboard Windows servers for this feature to work.
Open the VDI configuration package .zip file (WindowsDefenderATPOnboardingPackage.zip) that you downloaded from the service onboarding wizard. You can also get the package from the Microsoft 365 Defender portal:
In the navigation pane, select Settings > Endpoints > Device management > Onboarding.
Select the operating system.
In the Deployment method field, select VDI onboarding scripts for non-persistent endpoints.
Click Download package and save the .zip file.
Copy the files from the WindowsDefenderATPOnboardingPackage folder extracted from the .zip file into the golden/master image under the path
- If you are implementing multiple entries for each device - one for each session, copy WindowsDefenderATPOnboardingScript.cmd.
- If you're implementing a single entry for each device, copy both Onboard-NonPersistentMachine.ps1 and WindowsDefenderATPOnboardingScript.cmd.
If you don't see the
C:\WINDOWS\System32\GroupPolicy\Machine\Scripts\Startupfolder, it might be hidden. You'll need to choose the Show hidden files and folders option from File Explorer.
Open a Local Group Policy Editor window and navigate to Computer Configuration > Windows Settings > Scripts > Startup.
Domain Group Policy may also be used for onboarding non-persistent VDI devices.
Depending on the method you'd like to implement, follow the appropriate steps:
For single entry for each device:
Select the PowerShell Scripts tab, then click Add (Windows Explorer will open directly in the path where you copied the onboarding script earlier). Navigate to onboarding PowerShell script
Onboard-NonPersistentMachine.ps1. There's no need to specify the other file, as it will be triggered automatically.
For multiple entries for each device:
Select the Scripts tab, then click Add (Windows Explorer will open directly in the path where you copied the onboarding script earlier). Navigate to the onboarding bash script
Test your solution:
- Create a pool with one device.
- Log on to device.
- Log off from device.
- Log on to device with another user.
- Depending on the method you'd like to implement, follow the appropriate steps:
- For single entry for each device: Check only one entry in Microsoft 365 Defender portal.
- For multiple entries for each device: Check multiple entries in Microsoft 365 Defender portal.
Click Devices list on the Navigation pane.
Use the search function by entering the device name and select Device as search type.
For downlevel SKUs (Windows Server 2008 R2)
These instructions for other Windows server versions also apply if you are running the previous Microsoft Defender for Endpoint for Windows Server 2016 and Windows Server 2012 R2 that requires the MMA. Instructions to migrate to the new unified solution are at Server migration scenarios in Microsoft Defender for Endpoint.
The following registry is relevant only when the aim is to achieve a 'Single entry for each device'.
Set registry value to:
[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows Advanced Threat Protection\DeviceTagging] "VDI"="NonPersistent"
or using command line:
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows Advanced Threat Protection\DeviceTagging" /v VDI /t REG_SZ /d "NonPersistent" /f
Follow the server onboarding process.
Updating non-persistent virtual desktop infrastructure (VDI) images
With the ability to easily deploy updates to VMs running in VDIs, we've shortened this guide to focus on how you can get updates on your machines quickly and easily. You no longer need to create and seal golden images on a periodic basis, as updates are expanded into their component bits on the host server and then downloaded directly to the VM when it's turned on.
For more information, follow the guidance in Deployment guide for Microsoft Defender Antivirus in a Virtual Desktop Infrastructure (VDI) environment.
If you have onboarded the master image of your Non-Persistent VDI environment (SENSE service is running), then you must offboard and clear some data before putting the image back into production.
- Ensure the sensor is stopped by running the command below in a CMD window:
sc query sense
- Run the below commands using PsExec.exe (which can be downloaded from https://download.sysinternals.com/files/PSTools.zip)
PsExec.exe -s cmd.exe cd "C:\ProgramData\Microsoft\Windows Defender Advanced Threat Protection\Cyber" del *.* /f /s /q REG DELETE "HKLM\SOFTWARE\Microsoft\Windows Advanced Threat Protection" /v senseGuid /f exit
Submit and view feedback for