Test GPO WMI filter using Powershell

GPO WMI filters can get screwed up when edited. Quick way of testing a WMI filter is available using Powershell:

  1. Grab the GPO WMI filter from GPMC and put it into clipboard
  2. in Powershell console:
    gwmi -Query ‘Paste your WMI filter here’
    in words:
    write gwmi -Query ‘ (single qoute)
    paste in your wmi filter
    ‘ (single qoute) 

Result could look like this:
gwmi -Query ‘SELECT ProductType, CSName FROM Win32_OperatingSystem WHERE (ProductType = “1”) AND Not CSName = “CB002021”)

When any results are returned WMI filter evaluates to $true (GPO applies), else $false (GPO does not aplly)

Don’t forget that you get the luxury to test against multiple computer just by adding the -Computername parameter:

gwmi -Query ‘SELECT ProductType, CSName FROM Win32_OperatingSystem WHERE (ProductType = “1”) AND Not CSName = “CB002021”)‘ -Computername PC01,PC02

Advertisements

Tagged: , ,

One thought on “Test GPO WMI filter using Powershell

  1. Tomas Deceuninck 25.6.2014 at 11:33 Reply

    Reblogged this on Memory Extension and commented:
    Very useful when setting up new wmi filters.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

smsagent

Tips, tricks and time-savers for the Windows and ConfigMgr administrator

To The Point

Anything about Technology and Business

Brian's Power Windows Blog

Microsoft in the Enterprise. Windows, Hyper-V, Exchange, SQL, and more!

PowerScripting Podcast

Shownotes and links for the PowerScripting Podcast, a podcast to help people learn Windows Powershell

Learn Powershell | Achieve More

What is this Powershell of which you speak?

%d bloggers like this: