SCCM – SQL – Return Computers and IP Addresses

email me

SELECT 
A.Name0,c.IPAddress0 as "IP ADDRESS",E.UserName0 as "Lastlogged user"
FROM 
v_R_System A inner join
v_FullCollectionMembership B ON
A.ResourceID=B.ResourceID
INNER JOIN v_GS_NETWORK_ADAPTER_CONFIGUR C ON
A.ResourceID=C.ResourceID
INNER JOIN v_GS_COMPUTER_SYSTEM E ON A.ResourceID=E.ResourceID
WHERE 
C.IPEnabled0='1' AND c.ipaddress0 !='0.0.0.0'
/*WHERE CollectionID=@COLLID and C.IPEnabled0='1' AND c.ipaddress0 !='0.0.0.0'*/
GROUP BY 
A.Name0,c.IPAddress0 ,E.UserName0