I make heavy use of group policy in my home environment. It makes it very easy to push out defaults to all of my various computers and virtual machines. However, there are times when I have a setting that I only want applied to virtual machines. Luckily this is somewhat simple to do. You need to open the Group Policy Management console and go to the WMI Filters section.
Here you will want to create as many filters as make sense for your environment (as you can see, I have filters that divide my systems into physical and virtual as well as desktop or server).
Once you have created a filter you will want to add the following WMI filter to target virtual machines:
SELECT * FROM Win32_ComputerSystem WHERE Model = "Virtual Machine"
Finally, associate this filter with the group policy that you want applied to virtual machines in your environment.
Some quick notes:
- This will only target Hyper-V virtual machines. If you are using a different virtualization platform you will need to find out what model string that platform returns.
- To create a group policy that only targets physical computers, just change the ‘=’ to ‘!=’ in the WMI query