Windows OS Hub
  • Windows Server
    • Windows Server 2022
    • Windows Server 2019
    • Windows Server 2016
    • Windows Server 2012 R2
    • Windows Server 2012
    • Windows Server 2008 R2
    • SCCM
  • Active Directory
    • Active Directory Domain Services (AD DS)
    • Group Policies
  • Windows Clients
    • Windows 11
    • Windows 10
    • Windows 8
    • Windows 7
    • Windows XP
    • MS Office
    • Outlook
  • Virtualization
    • VMWare
    • Hyper-V
    • KVM
  • PowerShell
  • Exchange
  • Cloud
    • Azure
    • Microsoft 365
    • Office 365
  • Linux
    • CentOS
    • RHEL
    • Ubuntu
  • Home
  • About

Windows OS Hub

  • Windows Server
    • Windows Server 2022
    • Windows Server 2019
    • Windows Server 2016
    • Windows Server 2012 R2
    • Windows Server 2012
    • Windows Server 2008 R2
    • SCCM
  • Active Directory
    • Active Directory Domain Services (AD DS)
    • Group Policies
  • Windows Clients
    • Windows 11
    • Windows 10
    • Windows 8
    • Windows 7
    • Windows XP
    • MS Office
    • Outlook
  • Virtualization
    • VMWare
    • Hyper-V
    • KVM
  • PowerShell
  • Exchange
  • Cloud
    • Azure
    • Microsoft 365
    • Office 365
  • Linux
    • CentOS
    • RHEL
    • Ubuntu

 Windows OS Hub / Group Policies / Using WMI Filter to Apply Group Policy to IP Subnet

May 3, 2017 Group Policies

Using WMI Filter to Apply Group Policy to IP Subnet

This time it was necessary to apply GPO to computers in the specific IP subnet. In the simplest case, when the subnet is a part of a separate Active Directory site (and this is the only subnet in the site) you can assign your GPO to the AD site. It is a simple and easy method. In our case, we can’t apply the policy to the whole AD site since several IP subnets is bound to it. We’ll have to use the feature of filtering policies using WMI filters.

Earlier we have considered using WMI filters to apply the specific Group Policy only to the certain Windows versions. In this case, in the same way you have to create a WMI filter and change the query so that it contains the condition to check IP addresses.

  1. Open GPMC.msc (Group Policy Management) console and find WMI Filters section.
  2. Create a new filter. To do it, right-click the section and select New in the context menu.Create new GPO WMI filter
  3. Specify the filter name and its description.
  4. To add a WMI query  click Add.wmi filter on ip subnets
  5. Leave root\CIMv2 as a namespace, and copy the following code to the query window:
    Select * FROM Win32_IP4RouteTable
    WHERE (Mask='255.255.255.255'
    AND (Destination Like '191.168.55.%' OR Destination Like '191.168.56.%'))
    wmi query Win32_IP4RouteTable
    Note. In this example, we created a filter that allows to apply the policy to clients using IP address templates with masks 191.168.55.x and 191.168.56.x. Replace these subnets with your own ones.
  6. Save the query.
  7. In GPMC console, select the policy you want to apply.
  8. In the WMI Filtering section of this policy settings, select the created filter in the dropdown list and assign the policy to the OU containing the computers.link WMI filter to Group Policy
Note. In some cases, it is more convenient to target a policy to the specific client subnets with the targeting feature of Group Policy Preferences, where you can set a range of IP addresses in one of the filters.

Now you have to update the policies on the clients (gpupdate /force) and make sure they are applied. (To make sure if your GPO has been applied, you can use the standard utility gpresult).

So using a simple WMI filter we can assign a Group Policy to clients in the specific IP networks or to a range of IP addresses.

4 comments
0
Facebook Twitter Google + Pinterest
previous post
PowerShell Remoting via WinRM for Non-Admin Users
next post
Troubleshoot Slow GPO Processing and Login Speed Impact

Related Reading

Configure User’s Folder Redirection with Group Policy

February 3, 2023

Enable Internet Explorer (IE) Compatibility Mode in Microsoft...

January 27, 2023

How to Disable or Uninstall Internet Explorer (IE)...

January 26, 2023

How to Delete Old User Profiles in Windows?

January 25, 2023

Allow or Prevent Non-Admin Users from Reboot/Shutdown Windows

January 17, 2023

4 comments

lanny March 7, 2019 - 3:59 pm

what would the WMI be to also all Windows 10 and the subnet?

Reply
admin March 14, 2019 - 11:30 am

Just add the second WMI query in the WMI Filter window with the code:
select * from Win32_OperatingSystem WHERE Version LIKE “10.0%” and ProductType = “1”
ref. https://woshub.com/group-policy-filtering-using-wmi-filters/

Reply
sdfvsdfv gsdgfd December 26, 2021 - 6:16 pm

Any idea why this doesn’t work?

Select * FROM Win32_IP4RouteTable
WHERE (Mask=’255.255.255.255′
AND (Destination Like ‘191.168.4.%’ OR Destination Like ‘191.168.5.%’ OR Destination Like ‘191.168.33.%’ OR Destination Like ‘191.168.3.%’))

Reply
Nalar August 31, 2022 - 6:25 am

Maybe the IP-Adress should be corrected it has to be 192.168.3.% not 191.168.3.% i guess

Reply

Leave a Comment Cancel Reply

Categories

  • Active Directory
  • Group Policies
  • Exchange Server
  • Microsoft 365
  • Azure
  • Windows 11
  • Windows 10
  • Windows Server 2022
  • Windows Server 2019
  • Windows Server 2016
  • PowerShell
  • VMWare
  • Hyper-V
  • Linux
  • MS Office

Recent Posts

  • Configure User’s Folder Redirection with Group Policy

    February 3, 2023
  • Using Previous Command History in PowerShell Console

    January 31, 2023
  • How to Install the PowerShell Active Directory Module and Manage AD?

    January 31, 2023
  • Finding Duplicate E-mail (SMTP) Addresses in Exchange

    January 27, 2023
  • How to Delete Old User Profiles in Windows?

    January 25, 2023
  • How to Install Free VMware Hypervisor (ESXi)?

    January 24, 2023
  • How to Enable TLS 1.2 on Windows?

    January 18, 2023
  • Allow or Prevent Non-Admin Users from Reboot/Shutdown Windows

    January 17, 2023
  • Fix: Can’t Extend Volume in Windows

    January 12, 2023
  • Wi-Fi (Internet) Disconnects After Sleep or Hibernation on Windows 10/11

    January 11, 2023

Follow us

woshub.com
  • Facebook
  • Twitter
  • RSS
Popular Posts
  • Backup/Restore and Export Local Group Policy Settings to Another Computer
  • How to Configure a Slideshow Screensaver Using GPO
  • How to Block Viruses and Ransomware Using Software Restriction Policies
  • Troubleshoot Slow GPO Processing and Login Speed Impact
  • Defending Windows Domain Against Mimikatz Attacks
  • Securing Administrative (Priveleged) Accounts in Active Directory
  • Recovering Encrypted Files from VSS Snapshot after Ransomware Infection
Footer Logo

@2014 - 2023 - Windows OS Hub. All about operating systems for sysadmins


Back To Top