In this post, I will show you how to create a device collection for IIS servers in SCCM. By using a WQL query, you can find all the IIS enabled servers running in your Active Directory environment.

If you are wondering if SCCM requires IIS, the answer is YES. Several roles in Configuration Manager require the IIS role as a prerequisite for proper functioning. For instance, when you install the distribution point role on a server, the required IIS role and features are installed and configured by SCCM.

Recently, I got an email as well a question posted in SCCM forums asking for a dynamic WQL query that can group all the Windows servers installed with IIS role into a dedicated collection. This is absolutely possible, and I will show you how to do it. Learn more about collections in Configuration Manager.

Install and Update Third Party Applications with Patch My PC
Install and Update Third Party Applications withĀ PatchĀ MyĀ PC

WQL Query for IIS Enabled Servers

First, let me show you the easiest way to check if the IIS is running on the server. Open the services console (services.msc) and look for World Wide Web Publishing Service. Right-click this service and select Properties. Take a note of the Service name and display name.

  • Service name: W3SVC
  • Display name: World Wide Web Publishing Service
Identify IIS enabled servers with WQL Query
Identify IIS enabled servers with WQL Query

You can create a collection for IIS servers by using either the service name or the display name in a WQL query. Both queries have been provided, and you may use the one that is of your choice.

Use this WQL query to create a device collection for IIS servers using the service name: W3SVC.

select SMS_R_SYSTEM.ResourceID,SMS_R_SYSTEM.ResourceType,SMS_R_SYSTEM.Name,SMS_R_SYSTEM.SMSUniqueIdentifier,SMS_R_SYSTEM.ResourceDomainORWorkgroup,SMS_R_SYSTEM.Client from SMS_R_System inner join SMS_G_System_SERVICE on SMS_G_System_SERVICE.ResourceID = SMS_R_System.ResourceId where SMS_G_System_SERVICE.Name = "W3SVC"

Use this WQL query to create a device collection for IIS servers using the display name – World Wide Web Publishing Service.

select SMS_R_System.ResourceId, SMS_R_System.ResourceType, SMS_R_System.Name, SMS_R_System.SMSUniqueIdentifier, SMS_R_System.ResourceDomainORWorkgroup, SMS_R_System.Client from  SMS_R_System inner join SMS_G_System_SERVICE on SMS_G_System_SERVICE.ResourceID = SMS_R_System.ResourceId where SMS_G_System_SERVICE.DisplayName = "World Wide Web Publishing Service"

Create a Device Collection for IIS Servers

Here’s the procedure for creating a SCCM device collection for IIS enabled servers. Launch the Configuration Manager console and navigate to Assets and Compliance > Overview > Device Collections. Right click Device Collections and select Create Device Collection.

Create a Device Collection for IIS Servers in SCCM
Create a Device Collection for IIS Servers in SCCM

This brings up create device collection wizard. On the General tab, specify the name of the device collection as IIS Enabled Servers. Optionally, you may add a brief description for the collection. Click Browse and choose the limiting collection as All Desktops and Server Clients. Click Next.

Create a Device Collection for IIS Servers in SCCM
Create a Device Collection for IIS Servers in SCCM

On the Membership Rules page, click Add Rule and from the drop-down select Query Rule. With query rule, you dynamically update the membership of a collection based on a query that Configuration Manager runs on a schedule.

On the Query rule properties window, specify the name of the query as IIS WQL Query and click Edit Query Statement.

WQL Query for IIS enabled Servers
WQL Query for IIS enabled Servers

In the Query Language box, enter the below IIS WQL query.

select SMS_R_SYSTEM.ResourceID,SMS_R_SYSTEM.ResourceType,SMS_R_SYSTEM.Name,SMS_R_SYSTEM.SMSUniqueIdentifier,SMS_R_SYSTEM.ResourceDomainORWorkgroup,SMS_R_SYSTEM.Client from SMS_R_System inner join SMS_G_System_SERVICE on SMS_G_System_SERVICE.ResourceID = SMS_R_System.ResourceId where SMS_G_System_SERVICE.Name = "W3SVC"

Note: After entering the IIS WQL query, you can click on the Run Query to see the results instantly. This feature is also useful to test if the WQL query that you’ve entered is valid.

To save the entered query, click OK and close the Query Rule properties window. Click Next.

WQL Query for IIS enabled Server
WQL Query for IIS enabled Server

On the Summary window, review the collection settings and on Completion window click Close.

Create SCCM device collection for IIS enabled servers
Create SCCM device collection for IIS enabled servers

Wait for a few minutes while the query runs in the background, finding all the IIS enabled servers in your network. To speed up things, right-click the IIS server device collection and select Update Membership.

Update membership of IIS Servers device collection
Update membership of IIS Servers device collection

Once the collection has been updated, you should see the member count of devices running IIS in the Configuration Manager console. To view the device names installed with IIS role enabled, right-click the device collection and select Show Members. You can export these devices from the collection to a CSV file.

Devices with the IIS role enabled
Devices with the IIS role enabled

Troubleshooting

You may find the collection empty without any devices if you use an incorrect WQL query. If the device collection is not updating in the console, review theĀ colleval.log. The Colleval log records the details when collections are created, changed, and deleted by the Collection Evaluator.

Check out some useful guides related to collections in Configuration Manager.

Still Need Help?

If you need further assistance on the above article or want to discuss other technical issues, check out some of these options.

Prajwal Desai

Prajwal Desai is a technology expert and 10 time Dual Microsoft MVP (Most Valuable Professional) with a strong focus on Microsoft Intune, SCCM, Windows 365, Enterprise Mobility, and Windows. He is a renowned author, speaker, & community leader, known for sharing his expertise & knowledge through his blog, YouTube, conferences, webinars etc.