Score:0

WMI Filter Does not Apply After Updates

cn flag

I have a GPO with this WMI filter: SELECT Name From Win32_ServerFeature WHERE Name = 'Web Server (IIS)'

The GPO has a startup script meant to modify a file to instruct the load balancer that the server is OK to send traffic to.

Normally, when rebooting, the startup script runs. However, after installing patches, I noticed the server never went back into the load balancer. The startup script creates a log file, and I saw that the log file was never created for that reboot. I rebooted another time, and the startup script ran. I found the following event in EventViewer, which shows that the GPO was not applied due to WMI filtering:

Log Name:      Microsoft-Windows-GroupPolicy/Operational
Source:        Microsoft-Windows-GroupPolicy
Date:          5/4/2023 7:48:26 AM
Event ID:      5313
Task Category: None
Level:         Information
Keywords:      
User:          SYSTEM
Computer:      server01.mydomain
Description:
The following Group Policy objects were not applicable because they were filtered out : 

gpo.autoreboot.IIS_OK
    Denied (WMI Filter)

Event Xml:
<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
  <System>
    <Provider Name="Microsoft-Windows-GroupPolicy" Guid="{aea1b4fa-97d1-45f2-a64c-4d69fffd92c9}" />
    <EventID>5313</EventID>
    <Version>0</Version>
    <Level>4</Level>
    <Task>0</Task>
    <Opcode>0</Opcode>
    <Keywords>0x4000000000000000</Keywords>
    <TimeCreated SystemTime="2023-05-04T11:48:26.661096300Z" />
    <EventRecordID>274604</EventRecordID>
    <Correlation ActivityID="{ff168884-e55b-47c0-960c-40b500f178c2}" />
    <Execution ProcessID="1528" ThreadID="3212" />
    <Channel>Microsoft-Windows-GroupPolicy/Operational</Channel>
    <Computer>server01.mydomain</Computer>
    <Security UserID="S-1-5-18" />
  </System>
  <EventData>
    <Data Name="DescriptionString">gpo.autoreboot.IIS_OK
    Denied (WMI Filter)
</Data>
    <Data Name="GPOInfoList">&lt;GPO ID="{guid}"&gt;&lt;Name&gt;gpo.autoreboot.IIS_OK&lt;/Name&gt;&lt;Version&gt;131074&lt;/Version&gt;&lt;SOM&gt;LDAP://OU=servers,DC=mydomain&lt;/SOM&gt;&lt;FSPath&gt;\\mydomain\SysVol\mydomain\Policies\{guid}\Machine&lt;/FSPath&gt;&lt;Reason&gt;DENIED-WMIFILTER&lt;/Reason&gt;&lt;/GPO&gt;</Data>
  </EventData>
</Event>

Here's the Data element expanded and decoded:

<GPO ID="{guid}">
    <Name>gpo.autoreboot.IIS_OK</Name>
    <Version>131074</Version>
    <SOM>LDAP://OU=servers,DC=mydomain</SOM>
    <FSPath>\\mydomain\SysVol\mydomain\Policies\{guid}\Machine</FSPath>
    <Reason>DENIED-WMIFILTER</Reason>
</GPO>

A subsequent reboot did not have this event, and there was another event listing all the applied GPOs, which included this one. Is there something about updates that can prevent WMI filtering from working correctly on the Win32_ServerFeature class? If so, is there a workaround I can use to make sure this script only runs on IIS servers? I have thought about removing the WMI filter and just adding in a condition on the script that checks to see if the role is installed.

This happened on multiple servers with different OS versions, so I do not think it was a one-time event.

cn flag
The WMI query should have been tested before restarting. I would speculate at the time it ran, it had not completed the installation of updates, which may have temporarily affected the query results.
Micah Hunsberger avatar
cn flag
Is there a more reliable way then to make sure this applies to IIS servers? Updates are one of the primary reasons why a server would be restarted.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.