Partager via


SELECT * not working for IIS WMI providers

recently I was working on one issue where a simple WMI query was not returning all the proper results. It was a simple query as "SELECT * FROM IISWebVirtualDirSetting"

even tried using adsutil like this directly to get the results, still same results. We checked that the WMI functionality was itself working fine. So what was the issue ?

It turned out that  IIS WMI provider cannot handle custom IIS metabase setting like following entry:

<IIsConfigObject     Location ="/LM/W3SVC/1/ROOT/MyCustom-web"
                >
                <Custom
                                Name="AccessFlags"
                                ID="6016"
                                Value="AccessExecute | AccessRead"
                                Type="DWORD"
                                UserType="IIS_MD_UT_FILE"
                                Attributes="INHERIT"
                />
                <Custom
                                Name="AppFriendlyName"
                                ID="2102"
                                Value="eas-web"
                                Type="STRING"
                                UserType="IIS_MD_UT_FILE"
                                Attributes="INHERIT"
                />

 

The Workaround

1. Cerate a new virtual directory called "MyCustom-web-backup" and point the target folder to the same windows folder path.

2. iisreset -stop

3. look out for  " <IIsWebVirtualDir Location ="/LM/W3SVC/1/ROOT/ MyCustom-web-backup"   , and merge MyCustom-web elements into MyCustom-web-backup elements.

4. iisreset -start

5. Delete the old entries after renaming back the new entry from MyCustom-web-backup to MyCustom-web

 

speical thanks to Hui Zhu for finding this.