SCCM 2007 R2 – SQL Queries

To get an accurate list of computers to usernames vice versa, change the part in RED to suit

SELECT     v_R_System.Netbios_Name0, v_R_System.User_Name0, v_RA_System_IPAddresses.IP_Addresses0, v_RA_System_IPSubnets.IP_Subnets0,
                      v_GS_COMPUTER_SYSTEM.UserName0
FROM         v_R_System INNER JOIN
                      v_RA_System_IPAddresses ON v_R_System.ResourceID = v_RA_System_IPAddresses.ResourceID INNER JOIN
                      v_RA_System_IPSubnets ON v_R_System.ResourceID = v_RA_System_IPSubnets.ResourceID INNER JOIN
                      v_GS_COMPUTER_SYSTEM ON v_R_System.ResourceID = v_GS_COMPUTER_SYSTEM.ResourceID
WHERE     (v_RA_System_IPSubnets.IP_Subnets0 = ‘10.10.35.0‘)

Or………. From two subnets

SELECT     v_R_System.Netbios_Name0, v_R_System.User_Name0, v_RA_System_IPAddresses.IP_Addresses0, v_RA_System_IPSubnets.IP_Subnets0,
                      v_GS_COMPUTER_SYSTEM.UserName0
FROM         v_R_System INNER JOIN
                      v_RA_System_IPAddresses ON v_R_System.ResourceID = v_RA_System_IPAddresses.ResourceID INNER JOIN
                      v_RA_System_IPSubnets ON v_R_System.ResourceID = v_RA_System_IPSubnets.ResourceID INNER JOIN
                      v_GS_COMPUTER_SYSTEM ON v_R_System.ResourceID = v_GS_COMPUTER_SYSTEM.ResourceID
WHERE     (v_RA_System_IPSubnets.IP_Subnets0 = ‘10.10.35.0‘)
OR     (v_RA_System_IPSubnets.IP_Subnets0 = ‘10.10.65.0‘)

Computers and Internet Uncategorized

Leave a Reply

Please log in using one of these methods to post your comment:

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

%d bloggers like this: