I have a GPO with printers mapped via the user preferences. Each printer needs to be item-level targeted only to computers in a specific IP range. I have a list of about 92 ranges that need to be added to a dozen or so printers.

The only way I know of to add an IP range is to do it through the GUI by clicking New Item -> IP address range, then type each of the start and end addresses of the range, then hit Item Options -> OR (default is AND), then hit OK... 1 range at a time... for 12 printers.

There's no way in hell I'm doing this by hand!

Is there a way to script this? Or at least add ranges in a batch?

  • Which Windows Server version? – Davidw Sep 30 '19 at 18:49
  • Policy is being edited from a Win10 box with RSAT tools, but the domain functional level is 2012R2. Not that it matters though. The GUI interface for this hasn't changed since Server 2003/XP that I'm aware of. – Wes Sayeed Sep 30 '19 at 18:54
  • I didn't really expect any difference there myself, I was more wondering about Powershell in this regard. So far, my explorations into Powershell's group policy cmdlet's isn't proving fruitful. – Davidw Sep 30 '19 at 19:07
  • I'm looking into Swisstone's answer now. After making the edits to the XML, the challenge will be getting Group Policy to "uptake" the changes. – Wes Sayeed Sep 30 '19 at 19:09
  • I do see that there's a copy paste option in the item level targeting window. Edit, that doesn't seem to allow copy and paste between multiple printers. – Davidw Sep 30 '19 at 19:12

I can only give you a partial answer:

The Preferences are XML files. You can find the corresponding file here: \\YOUR_DOMAIN\SYSVOL\DOMAIN_NAME\Policies\ID_OF_THE_GPO\Machine\Preferences\Printers\Printers.xml

and you'll find something like that: XML Definitions of a Printers GPP File

As you can see, the filters are in the <Filters> node: so, you can create them with a script/editor for example (I know that this is not necessarily the easyiest part...)


To update the GPO version in AD, I recommend that, once you did your modifications in the XML file: open the GPO, change and restore any setting in a user preference, and then close the Group Policy Editor. Thus, the AD will increment the version of the GPO and the clients will properly download the new version.

  • Editing the XML worked like a champ. – Wes Sayeed Sep 30 '19 at 22:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.