Install BgInfo
- Download BgInfo: http://technet.microsoft.com/en-us/sysinternals/bb897557.aspx
- Run BgInfo.exe, prepare the fields to display and then save your template in a mysettings.bgi file
- Copy the exe and the bgi files on a share accessible to all VM, for example \\network\share
In Group Policy Management Editor
- Select the domain, right click, choose Create a GPO in this domain and link it here. Call it Virtual Machines Only, for instance.
- Edit this GPO, go to User Configuration > Policies > Windows Settings > Scripts (Logon/Logoff) and then double-click on Logon
- Script name \\network\share\bginfo\Bginfo.exe
- Script parameters \\network\share\bginfo\mysettings.bgi /TIMER:00 /nolicprompt
- (in various articles I saw the usage of a .bat file which also regedit to remove the license prompt; however it didn't work for me for some reason)
Now we need to filter which machines the GPO applies to. This is quite easy using WMI filters. In Group Policy Management Editor:
- Select the domain, then the WMI filters tree under it
- Create a new WMI filter, call it Virtual Machines for instance
- Edit the new WMI filter, add a Query
- the query must be in root\CIMv2 namespace and looks like that
SELECT * FROM Win32_ComputerSystem WHERE Model = "Virtual Machine"
- Last but not least, under "GPOs that use this WMI filter", click Add and select the Virtual Machines Only GPO. That should be it!
Troubleshooting:
- Update GPOs on a VM by running gpupdate /force (in this case, logging out is mandatory as our script runs at logon)
- See which GPOs are in effect by running gpresult /r (you will see if the Virtual Machines Only GPO is active)
- Run WMI queries using wbemtest
Bonus:
- I wanted to run another GPO on physical windows servers only. It turns out that WMI is not good with joins, so the easiest way is to have a WMI filter with 2 distinct queries in it
SELECT * FROM Win32_ComputerSystem WHERE Model != "Virtual Machine" SELECT * FROM Win32_OperatingSystem WHERE ProductType = "2" OR ProductType = "3"
Sources: