Share via


SCCM Collection query using IP range

Question

Thursday, October 19, 2017 11:08 AM

I simply need to have a collection to my IP range which should have all computers belong to that IP range.

All replies (14)

Thursday, October 19, 2017 12:59 PM

So what does your query look like now? What error / issue are you having with it?

Garth Jones

Blog: http://www.enhansoft.com/blog Old Blog: http://smsug.ca/blogs/garth_jones/default.aspx

Twitter: @GarthMJ Book: System Center Configuration Manager Reporting Unleased


Friday, October 20, 2017 5:37 AM

Hi,

Refer to below WQL query, change it according to your requirement.

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 where  SMS_R_System.IPSubnets like '192.168.100.0'

Please remember to mark the replies as answers if they help. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.


Friday, October 20, 2017 6:20 AM

So what does your query look like now? What error / issue are you having with it?

Garth Jones

Blog: http://www.enhansoft.com/blog Old Blog: http://smsug.ca/blogs/garth_jones/default.aspx

Twitter: @GarthMJ Book: System Center Configuration Manager Reporting Unleased

The issue is I do not have an option to query using an IP range, I have an option to query it using IP Subnet or IP Address. If I select IP Subnet, by default it shows all as ends with .0 (Ex: 192.168.10.0 or 192.168.50.0) but if want to get PC's with IP range between "156.140.160.21 -- 156.140.161.253", none of the query works as expected.


Friday, October 20, 2017 6:24 AM

Hi,

Refer to below WQL query, change it according to your requirement.

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 where  SMS_R_System.IPSubnets like '192.168.100.0'

Please remember to mark the replies as answers if they help. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

Hi lorry Luo,

Thanks for your update, I already tried this with many options as Greater then or equal to and Lesser than or equal to with no results.

Even I have tried it with Network Adapter configuration as well, still no luck. I want to get PC's with IP range between "156.140.160.21 -- 156.140.161.253", please let us know, If you have any query which will work for my scenario.

Thanks!


Friday, October 20, 2017 7:03 AM

Hi,

Maybe you can try to this one:

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 where  SMS_R_System.IPSubnets like ''156.140.160.2%" or SMS_R_System.IPSubnets like "156.140.161.%"

Please remember to mark the replies as answers if they help. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.


Friday, October 20, 2017 11:24 AM

First off you can't use greater than or less than because an ip address is not a number, it is a string. as such it will give you odd results. 

Yes you can create a query for this but it is not super simple.   if you take Lorry's query and run it you will notice that it will not include any computers between  156.140.160.30 - 156.140.160.199 As such you will need to adjust it to first exclude 156.140.161.254, then you will need it to include the range I listed above. To do this, you will need to use a single character wildcard, the character is a underscore. 

Garth Jones

Blog: http://www.enhansoft.com/blog Old Blog: http://smsug.ca/blogs/garth_jones/default.aspx

Twitter: @GarthMJ Book: System Center Configuration Manager Reporting Unleased


Tuesday, October 24, 2017 7:51 AM | 1 vote

Hi,

Maybe you can try to this one:

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 where  SMS_R_System.IPSubnets like ''156.140.160.2%" or SMS_R_System.IPSubnets like "156.140.161.%"

Please remember to mark the replies as answers if they help. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

Hi Lorry,

Thanks for your update, I already tried this but, It doesn't help us. Even I tried only with below query just to test whether it returns any results but it doesn't give any result.

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 where  SMS_R_System.IPSubnets like "156.140.161.%" 

Regards,

Prabhakaran C


Tuesday, October 24, 2017 8:01 AM

First off you can't use greater than or less than because an ip address is not a number, it is a string. as such it will give you odd results. 

Yes you can create a query for this but it is not super simple.   if you take Lorry's query and run it you will notice that it will not include any computers between  156.140.160.30 - 156.140.160.199 As such you will need to adjust it to first exclude 156.140.161.254, then you will need it to include the range I listed above. To do this, you will need to use a single character wildcard, the character is a underscore. 

Garth Jones

Blog: http://www.enhansoft.com/blog Old Blog: http://smsug.ca/blogs/garth_jones/default.aspx

Twitter: @GarthMJ Book: System Center Configuration Manager Reporting Unleased

Hi Garth,

I appreciate your response on this. Could you please help me to find a query just to fetch the the PC's within this IP range(156.140.161.45 to 156.140.161.55), so that i can modify the query accordingly.

The reason for asking is, i am not sure to fetch the PC's using IP address of the PC's from which table listed below.

SMS_R_System.IPSubnets

SMS_R_System.IPAddress

NetworkAdaptorConfiguration.IPAddress

Regards,

Prabhakaran C


Tuesday, October 24, 2017 2:19 PM

Really you should use the network adaptor one. since I am at it/dev connections this week and no where near my lab. I can write this for you.

Garth Jones

Blog: http://www.enhansoft.com/blog Old Blog: http://smsug.ca/blogs/garth_jones/default.aspx

Twitter: @GarthMJ Book: System Center Configuration Manager Reporting Unleased


Tuesday, October 24, 2017 4:15 PM

You can write something like this and it works for me. Get list of clients with ip range 10.181.142.1-10.181.142.254

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_NETWORK_ADAPTER_CONFIGURATION on SMS_G_System_NETWORK_ADAPTER_CONFIGURATION.ResourceId = SMS_R_System.ResourceId where SMS_G_System_NETWORK_ADAPTER_CONFIGURATION.IPAddress >= "10.181.142.1" and SMS_G_System_NETWORK_ADAPTER_CONFIGURATION.IPAddress <= "10.181.142.254" and SMS_G_System_NETWORK_ADAPTER_CONFIGURATION.DHCPEnabled = 1

Eswar Koneti | Configmgr Blog: http://www.eskonr.com | Linkedin: eskonr | Twitter: @eskonr


Friday, October 27, 2017 2:49 AM

Really you should use the network adaptor one. since I am at it/dev connections this week and no where near my lab. I can write this for you.

Garth Jones

Blog: http://www.enhansoft.com/blog Old Blog: http://smsug.ca/blogs/garth_jones/default.aspx

Twitter: @GarthMJ Book: System Center Configuration Manager Reporting Unleased

Thanks Garth,

I will wait for an update from you.

Regards,

Prabhakaran C


Friday, October 27, 2017 2:51 AM

You can write something like this and it works for me. Get list of clients with ip range 10.181.142.1-10.181.142.254

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_NETWORK_ADAPTER_CONFIGURATION on SMS_G_System_NETWORK_ADAPTER_CONFIGURATION.ResourceId = SMS_R_System.ResourceId where SMS_G_System_NETWORK_ADAPTER_CONFIGURATION.IPAddress >= "10.181.142.1" and SMS_G_System_NETWORK_ADAPTER_CONFIGURATION.IPAddress <= "10.181.142.254" and SMS_G_System_NETWORK_ADAPTER_CONFIGURATION.DHCPEnabled = 1

Eswar Koneti | Configmgr Blog: http://www.eskonr.com | Linkedin: eskonr | Twitter: @eskonr

Hi Eswar,

Thanks, I already tried this, but didn't get expected result. I will give a try again and update you accordingly.

Regards,

Prabhakaran C


Friday, October 27, 2017 5:47 AM

where SMS_G_System_NETWORK_ADAPTER_CONFIGURATION.IPAddress >= "10.181.142.1" and SMS_G_System_NETWORK_ADAPTER_CONFIGURATION.IPAddress <= "10.181.142.254"

Using less / greater than will do a string comparison imho (as Garth already mentioned) so the results might not be the expected ones.

Prabhakaran C: what do you want to achieve exactly? Why do you Need that Collection?

Torsten Meringer | http://www.mssccmfaq.de


Friday, October 27, 2017 4:27 PM

Really you should use the network adaptor one. since I am at it/dev connections this week and no where near my lab. I can write this for you.

Garth Jones

Blog: http://www.enhansoft.com/blog Old Blog: http://smsug.ca/blogs/garth_jones/default.aspx

Twitter: @GarthMJ Book: System Center Configuration Manager Reporting Unleased

Thanks Garth,

I will wait for an update from you.

Regards,

Prabhakaran C

I'm still at It/Dev connections until mid next week. So you will be waiting a while before I get access to my lab again.

Garth Jones

Blog: http://www.enhansoft.com/blog Old Blog: http://smsug.ca/blogs/garth_jones/default.aspx

Twitter: @GarthMJ Book: System Center Configuration Manager Reporting Unleased