<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-4854976060941534129</id><updated>2023-06-22T05:45:12.856-07:00</updated><title type='text'>JJ&#39;s SQL Ethiques- Blogging SMS/SCCM</title><subtitle type='html'>Scripting around SMS/SCCM...</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://jj-with-mad-skillz.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4854976060941534129/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://jj-with-mad-skillz.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/4854976060941534129/posts/default?start-index=26&amp;max-results=25&amp;redirect=false'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/05411953615495526418</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>54</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-4854976060941534129.post-3179432769880031308</id><published>2011-06-08T05:45:00.000-07:00</published><updated>2011-06-08T05:45:26.176-07:00</updated><title type='text'>SMS Report to find machines with duplicate serial numbers</title><content type='html'>SELECT&lt;br /&gt;
a.Name0,&lt;br /&gt;
a.UserName0,&lt;br /&gt;
d.sms_installed_sites0 as &#39;Site Code&#39;,&lt;br /&gt;
e.Lasthwscan as &#39;Last hardware Scan&#39;,&lt;br /&gt;
repeat.SerialNumber0&lt;br /&gt;
FROM&lt;br /&gt;
v_GS_COMPUTER_SYSTEM a,v_r_system c,v_RA_System_SMSInstalledSites d,v_GS_WORKSTATION_STATUS e,&lt;br /&gt;
v_GS_PC_BIOS b,&lt;br /&gt;
(SELECT b.SerialNumber0 FROM v_GS_PC_BIOS b GROUP BY&lt;br /&gt;
b.SerialNumber0 HAVING (Count(b.SerialNumber0)&gt;1)) as&lt;br /&gt;
repeat&lt;br /&gt;
WHERE&lt;br /&gt;
b.ResourceID = a.ResourceID&lt;br /&gt;
and a.ResourceID=c.resourceid&lt;br /&gt;
and b.resourceid=d.resourceid&lt;br /&gt;
and b.resourceid=e.resourceid&lt;br /&gt;
and b.SerialNumber0 = repeat.SerialNumber0&lt;br /&gt;
and (c.client0=1 and c.obsolete0=0 and c.Active0=1)&lt;br /&gt;
order by&lt;br /&gt;
b.SerialNumber0,&lt;br /&gt;
a.Name0,&lt;br /&gt;
a.UserName0</content><link rel='replies' type='application/atom+xml' href='http://jj-with-mad-skillz.blogspot.com/feeds/3179432769880031308/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jj-with-mad-skillz.blogspot.com/2011/06/sms-report-to-find-machines-with.html#comment-form' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4854976060941534129/posts/default/3179432769880031308'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4854976060941534129/posts/default/3179432769880031308'/><link rel='alternate' type='text/html' href='http://jj-with-mad-skillz.blogspot.com/2011/06/sms-report-to-find-machines-with.html' title='SMS Report to find machines with duplicate serial numbers'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/05411953615495526418</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4854976060941534129.post-7839425749561438417</id><published>2011-04-01T00:18:00.001-07:00</published><updated>2011-04-01T00:18:24.787-07:00</updated><title type='text'>Collection query to find all machines with 1 GB or more free space in C Drive</title><content type='html'>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_LOGICAL_DISK on SMS_G_System_LOGICAL_DISK.ResourceID = SMS_R_System.ResourceId where SMS_R_System.Client = 1 and SMS_R_System.Obsolete = 0 and SMS_R_System.Active = 1 and SMS_G_System_LOGICAL_DISK.DriveType = 3 and SMS_G_System_LOGICAL_DISK.DeviceID = &quot;C:&quot; and SMS_G_System_LOGICAL_DISK.FreeSpace &gt;= 1024</content><link rel='replies' type='application/atom+xml' href='http://jj-with-mad-skillz.blogspot.com/feeds/7839425749561438417/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jj-with-mad-skillz.blogspot.com/2011/04/collection-query-to-find-all-machines.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4854976060941534129/posts/default/7839425749561438417'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4854976060941534129/posts/default/7839425749561438417'/><link rel='alternate' type='text/html' href='http://jj-with-mad-skillz.blogspot.com/2011/04/collection-query-to-find-all-machines.html' title='Collection query to find all machines with 1 GB or more free space in C Drive'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/05411953615495526418</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4854976060941534129.post-3756788192573490162</id><published>2011-03-18T09:21:00.001-07:00</published><updated>2011-03-18T09:21:33.594-07:00</updated><title type='text'>Collection query to find windows 2003 server with Service pack 1 version</title><content type='html'>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_OPERATING_SYSTEM on SMS_G_System_OPERATING_SYSTEM.ResourceID = SMS_R_System.ResourceId where SMS_R_System.Obsolete = 0 and SMS_R_System.Client = 1 and SMS_G_System_OPERATING_SYSTEM.Caption like &quot;%windows%2003%&quot; and SMS_G_System_OPERATING_SYSTEM.CSDVersion like &quot;Service Pack 1&quot;</content><link rel='replies' type='application/atom+xml' href='http://jj-with-mad-skillz.blogspot.com/feeds/3756788192573490162/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jj-with-mad-skillz.blogspot.com/2011/03/collection-query-to-find-windows-2003.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4854976060941534129/posts/default/3756788192573490162'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4854976060941534129/posts/default/3756788192573490162'/><link rel='alternate' type='text/html' href='http://jj-with-mad-skillz.blogspot.com/2011/03/collection-query-to-find-windows-2003.html' title='Collection query to find windows 2003 server with Service pack 1 version'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/05411953615495526418</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4854976060941534129.post-2550510769195394769</id><published>2011-02-17T07:19:00.000-08:00</published><updated>2011-02-17T07:19:36.218-08:00</updated><title type='text'>Collection query to find machines without MS Office versions</title><content type='html'>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 Client = 1 and Obsolete = 0 and Active = 1 and OperatingSystemNameandVersion not like &quot;%server%&quot; and ResourceId not in (select RESOURCEID  from  SMS_R_System inner join SMS_G_System_SoftwareFile on SMS_G_System_SoftwareFile.ResourceID = SMS_R_System.ResourceId where (SMS_G_System_SoftwareFile.FileName like &quot;excel.exe&quot; or SMS_G_System_SoftwareFile.FileName like &quot;winword.exe&quot;))&lt;br /&gt;
&lt;br /&gt;
Description: There are different ways to reach out to this solution. The above method is by using software inventory and querying machines with &#39;excel.exe&#39; or &#39;winword.exe&#39;. If these exe&#39;s present on the machines, it is assumed that it have MS office installed. You can go for additional conditions in the filepath column and restrict it to find only in program files folder etc etc. But this should almost do your job. Once you write this query, then using SUBSELECT method you can filter the machines which don;t have this software. &lt;br /&gt;
&lt;br /&gt;
Also you can make use of mso.dll and adding a filepath condition should do. Another method is by making hardware inventory data from your add or remove programs and querying the displayname. This i won&#39;t recommend because you have to put lot of displaynames (ms office 2003, ms office 2007, ms office XP proffessional, ms office enterprise% etc etc) to make sure you are getting accurate result. If you are sure about what are the exact displaynames then go for this. whichever method you choose, you need to make a subselect query to get it done. &lt;br /&gt;
&lt;br /&gt;
Good Luck!</content><link rel='replies' type='application/atom+xml' href='http://jj-with-mad-skillz.blogspot.com/feeds/2550510769195394769/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jj-with-mad-skillz.blogspot.com/2011/02/collection-query-to-find-machines.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4854976060941534129/posts/default/2550510769195394769'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4854976060941534129/posts/default/2550510769195394769'/><link rel='alternate' type='text/html' href='http://jj-with-mad-skillz.blogspot.com/2011/02/collection-query-to-find-machines.html' title='Collection query to find machines without MS Office versions'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/05411953615495526418</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4854976060941534129.post-8220006448258246111</id><published>2011-01-24T10:24:00.000-08:00</published><updated>2011-01-24T10:24:03.594-08:00</updated><title type='text'>SMS Report/Query to find the current IP Address of client machines</title><content type='html'>SELECT&lt;br /&gt;
[ComputerName],&lt;br /&gt;
[IP Address],&lt;br /&gt;
[Subnet Mask],&lt;br /&gt;
[Timestamp]&lt;br /&gt;
FROM&lt;br /&gt;
(&lt;br /&gt;
select &lt;br /&gt;
row_number() over (partition by cfg.IPAddress0 order by cfg.Timestamp desc) as rownum,&lt;br /&gt;
sys.netbios_name0 AS [ComputerName],&lt;br /&gt;
cfg.IPAddress0 AS [IP Address],&lt;br /&gt;
cfg.IPSubnet0 AS [Subnet Mask],&lt;br /&gt;
cfg.Timestamp AS [Timestamp]&lt;br /&gt;
FROM&lt;br /&gt;
dbo.v_R_System AS sys&lt;br /&gt;
INNER JOIN dbo.v_GS_Network_Adapter_Configur AS cfg&lt;br /&gt;
ON sys.resourceID = cfg.resourceID&lt;br /&gt;
AND cfg.IPEnabled0 = 1&lt;br /&gt;
WHERE&lt;br /&gt;
sys.obsolete0 = 0&lt;br /&gt;
AND sys.decommissioned0 = 0&lt;br /&gt;
AND sys.client0 = 1&lt;br /&gt;
AND sys.Obsolete0=0&lt;br /&gt;
AND cfg.IPaddress0 NOT LIKE &#39;%,%&#39;&lt;br /&gt;
AND cfg.IPAddress0 NOT LIKE &#39;0.0%&#39;)as dt&lt;br /&gt;
where rownum=1&lt;br /&gt;
order by [Timestamp] desc</content><link rel='replies' type='application/atom+xml' href='http://jj-with-mad-skillz.blogspot.com/feeds/8220006448258246111/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jj-with-mad-skillz.blogspot.com/2011/01/sms-reportquery-to-find-current-ip.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4854976060941534129/posts/default/8220006448258246111'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4854976060941534129/posts/default/8220006448258246111'/><link rel='alternate' type='text/html' href='http://jj-with-mad-skillz.blogspot.com/2011/01/sms-reportquery-to-find-current-ip.html' title='SMS Report/Query to find the current IP Address of client machines'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/05411953615495526418</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4854976060941534129.post-1586351633572533840</id><published>2011-01-21T07:02:00.001-08:00</published><updated>2011-02-23T03:59:19.251-08:00</updated><title type='text'>SMS Report to list all the machines that haven&#39;t reported its discovery/inventory since past 30 days</title><content type='html'>select sys.Netbios_Name0,&lt;br /&gt;
sys.Client_Type0,&lt;br /&gt;
sys.Creation_date0 as &#39;Creation Date&#39;,&lt;br /&gt;
sys.Client_Version0,&lt;br /&gt;
sys.User_Domain0,&lt;br /&gt;
sys.User_Name0,&lt;br /&gt;
inst.sms_assigned_sites0 as &#39;sitecode&#39;,&lt;br /&gt;
disc.AgentTime as &#39;Last Discovery date&#39;,&lt;br /&gt;
hw.LastHWScan as &#39;Last HW Scan&#39;,&lt;br /&gt;
sw.LastScanDate as &#39;Last SW Scan&#39;&lt;br /&gt;
from v_R_System sys&lt;br /&gt;
left join &lt;br /&gt;
(&lt;br /&gt;
select ResourceId, MAX(AgentTime) as AgentTime&lt;br /&gt;
from v_AgentDiscoveries&lt;br /&gt;
group by ResourceId&lt;br /&gt;
) as disc on disc.ResourceId = sys.ResourceID&lt;br /&gt;
left join v_GS_WORKSTATION_STATUS hw on hw.ResourceID = sys.ResourceID&lt;br /&gt;
left join v_GS_LastSoftwareScan sw on sw.ResourceID = sys.ResourceID&lt;br /&gt;
left join v_RA_System_SMSAssignedSites inst on inst.resourceid=sys.resourceid&lt;br /&gt;
where &lt;br /&gt;
disc.AgentTime &lt; getdate()-30&lt;br /&gt;
or hw.LastHWScan &lt; getdate()-30&lt;br /&gt;
or sw.LastScanDate &lt; getdate()-30&lt;br /&gt;
and (sys.Client0 = 1 and sys.Obsolete0=0)&lt;br /&gt;
and sys.Name0 in (SELECT Name0&lt;br /&gt;
FROM v_r_system&lt;br /&gt;
GROUP BY Name0&lt;br /&gt;
HAVING COUNT(*) &lt; 2)&lt;br /&gt;
order by disc.AgentTime asc</content><link rel='replies' type='application/atom+xml' href='http://jj-with-mad-skillz.blogspot.com/feeds/1586351633572533840/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jj-with-mad-skillz.blogspot.com/2011/01/sms-report-to-list-all-machines-that.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4854976060941534129/posts/default/1586351633572533840'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4854976060941534129/posts/default/1586351633572533840'/><link rel='alternate' type='text/html' href='http://jj-with-mad-skillz.blogspot.com/2011/01/sms-report-to-list-all-machines-that.html' title='SMS Report to list all the machines that haven&#39;t reported its discovery/inventory since past 30 days'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/05411953615495526418</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4854976060941534129.post-7279570033068710092</id><published>2011-01-13T08:40:00.000-08:00</published><updated>2011-01-13T08:40:23.946-08:00</updated><title type='text'>Collection Query based off specific model and bios version</title><content type='html'>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_COMPUTER_SYSTEM on SMS_G_System_COMPUTER_SYSTEM.ResourceID = SMS_R_System.ResourceId inner join SMS_G_System_PC_BIOS on SMS_G_System_PC_BIOS.ResourceID = SMS_R_System.ResourceId where SMS_G_System_COMPUTER_SYSTEM.Model like &quot;OptiPlex 380&quot; and SMS_G_System_PC_BIOS.SMBIOSBIOSVersion &lt; &quot;A04&quot; and SMS_R_System.Client = 1 and SMS_R_System.Obsolete = 0&lt;br /&gt;
&lt;br /&gt;
Description: This query lists all the OptiPlex 380 machine models which is having a bios version less than A04.</content><link rel='replies' type='application/atom+xml' href='http://jj-with-mad-skillz.blogspot.com/feeds/7279570033068710092/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jj-with-mad-skillz.blogspot.com/2011/01/collection-query-based-off-specific.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4854976060941534129/posts/default/7279570033068710092'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4854976060941534129/posts/default/7279570033068710092'/><link rel='alternate' type='text/html' href='http://jj-with-mad-skillz.blogspot.com/2011/01/collection-query-based-off-specific.html' title='Collection Query based off specific model and bios version'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/05411953615495526418</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4854976060941534129.post-7110669525482053021</id><published>2011-01-13T06:55:00.000-08:00</published><updated>2011-01-13T06:55:04.803-08:00</updated><title type='text'>Query to find Number of days count of all client machines since Last Bootuptime</title><content type='html'>select a.Netbios_name0, e.Caption0 as OS, e.CSDversion0 as &#39;SP level&#39;,a.resourceid,a.Creation_date0,a.client0, a.ad_site_name0,a.obsolete0,&lt;br /&gt;
b.sms_installed_sites0 as &#39;sitecode&#39;,c.Lasthwscan,d.Agenttime  as &#39;Last heartbeat discovery ran&#39;,e.LastBootUpTime0,DATEDIFF(dd, LastBootUpTime0, GETDATE())AS &#39;Number of Days since last bootup&#39;&lt;br /&gt;
from v_r_system a&lt;br /&gt;
left outer join v_RA_System_SMSInstalledSites b on a.resourceid=b.resourceid&lt;br /&gt;
left outer join v_GS_WORKSTATION_STATUS c on a.resourceid=c.resourceid&lt;br /&gt;
Left outer join v_AgentDiscoveries d on d.resourceid=a.resourceid&lt;br /&gt;
left outer join v_gs_operating_system e on e.resourceid=a.resourceid&lt;br /&gt;
where d.AgentName=&#39;Heartbeat Discovery&#39; and (a.client0=1 and a.Obsolete0=0 and a.Active0=1)&lt;br /&gt;
and a.Name0 IN (SELECT Name0&lt;br /&gt;
                   FROM v_r_system&lt;br /&gt;
                   GROUP BY Name0&lt;br /&gt;
                   HAVING COUNT(*) &lt; 2)&lt;br /&gt;
order by e.LastBootUpTime0 desc</content><link rel='replies' type='application/atom+xml' href='http://jj-with-mad-skillz.blogspot.com/feeds/7110669525482053021/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jj-with-mad-skillz.blogspot.com/2011/01/query-to-find-number-of-days-count-of.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4854976060941534129/posts/default/7110669525482053021'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4854976060941534129/posts/default/7110669525482053021'/><link rel='alternate' type='text/html' href='http://jj-with-mad-skillz.blogspot.com/2011/01/query-to-find-number-of-days-count-of.html' title='Query to find Number of days count of all client machines since Last Bootuptime'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/05411953615495526418</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4854976060941534129.post-7064690611042947899</id><published>2011-01-11T07:15:00.001-08:00</published><updated>2011-01-11T07:15:26.549-08:00</updated><title type='text'>Query to find Bootuptime of all SMS client machines for a specific time frame</title><content type='html'>select a.Netbios_name0, e.Caption0 as OS, e.CSDversion0 as &#39;SP level&#39;,a.resourceid,a.Creation_date0,a.client0, a.ad_site_name0,a.obsolete0,&lt;br /&gt;
b.sms_installed_sites0 as &#39;sitecode&#39;,e.LastBootUpTime0,c.Lasthwscan,d.Agenttime as &#39;Last heartbeat discovery ran&#39;&lt;br /&gt;
from v_r_system a&lt;br /&gt;
left outer join v_RA_System_SMSInstalledSites b on a.resourceid=b.resourceid&lt;br /&gt;
left outer join v_GS_WORKSTATION_STATUS c on a.resourceid=c.resourceid&lt;br /&gt;
Left outer join v_AgentDiscoveries d on d.resourceid=a.resourceid&lt;br /&gt;
left outer join v_gs_operating_system e on e.resourceid=a.resourceid&lt;br /&gt;
where d.AgentName=&#39;Heartbeat Discovery&#39; and d.Agenttime &gt;=getdate()-30</content><link rel='replies' type='application/atom+xml' href='http://jj-with-mad-skillz.blogspot.com/feeds/7064690611042947899/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jj-with-mad-skillz.blogspot.com/2011/01/query-to-find-bootuptime-of-all-sms.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4854976060941534129/posts/default/7064690611042947899'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4854976060941534129/posts/default/7064690611042947899'/><link rel='alternate' type='text/html' href='http://jj-with-mad-skillz.blogspot.com/2011/01/query-to-find-bootuptime-of-all-sms.html' title='Query to find Bootuptime of all SMS client machines for a specific time frame'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/05411953615495526418</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4854976060941534129.post-6333287150768381034</id><published>2010-12-29T03:30:00.000-08:00</published><updated>2010-12-29T03:30:58.338-08:00</updated><title type='text'>SMS Report for the packages advertised but not yet updated the DP</title><content type='html'>SELECT a.AdvertisementID,a.AdvertisementName,a.PresentTime as &#39;Advert Start Date&#39;,b.Name as &#39;Package Name&#39;,b.PackageID,count(b.PackageID) as &#39;Count of pending DP&#39;&lt;br /&gt;
FROM v_Advertisement a&lt;br /&gt;
INNER JOIN v_Package b ON a.PackageID = b.PackageID&lt;br /&gt;
INNER JOIN v_DistributionPoint c ON b.PackageID = c.PackageID&lt;br /&gt;
INNER JOIN v_PackageStatusDistPointsSumm d ON c.PackageID = d.PackageID&lt;br /&gt;
WHERE d.state=1&lt;br /&gt;
GROUP BY a.AdvertisementID,a.AdvertisementName,a.PresentTime,b.PackageID,b.Name&lt;br /&gt;
&lt;br /&gt;
Description: This report gives the count of each distribution points in which a specific advertised package is not updated.</content><link rel='replies' type='application/atom+xml' href='http://jj-with-mad-skillz.blogspot.com/feeds/6333287150768381034/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jj-with-mad-skillz.blogspot.com/2010/12/sms-report-for-packages-advertised-but.html#comment-form' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4854976060941534129/posts/default/6333287150768381034'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4854976060941534129/posts/default/6333287150768381034'/><link rel='alternate' type='text/html' href='http://jj-with-mad-skillz.blogspot.com/2010/12/sms-report-for-packages-advertised-but.html' title='SMS Report for the packages advertised but not yet updated the DP'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/05411953615495526418</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4854976060941534129.post-8894258354769813753</id><published>2010-12-15T06:33:00.000-08:00</published><updated>2010-12-15T06:33:56.425-08:00</updated><title type='text'>Query to find non sms clients with recent AD discovery</title><content type='html'>SELECT &lt;br /&gt;
 [Name],&lt;br /&gt;
[Resourceid],&lt;br /&gt;
[Obsolete],&lt;br /&gt;
[Client],&lt;br /&gt;
[LastSWscan],&lt;br /&gt;
[LastHWscan],&lt;br /&gt;
[Last discovery run]&lt;br /&gt;
FROM&lt;br /&gt;
(SELECT &lt;br /&gt;
row_number() over (partition by a.Name0 order by e.AgentTime desc) as rownum,&lt;br /&gt;
        a.Name0 as [Name],&lt;br /&gt;
 a.resourceid as [Resourceid],&lt;br /&gt;
        a.Obsolete0 as [Obsolete],&lt;br /&gt;
        a.Client0 as [Client],&lt;br /&gt;
        b.LastScandate AS [LastSWscan],&lt;br /&gt;
        c.LastHWscan as [LastHWscan],&lt;br /&gt;
 e.AgentTime as [Last discovery run]&lt;br /&gt;
FROM v_r_system AS a&lt;br /&gt;
LEFT OUTER JOIN v_GS_LastSoftwareScan AS b&lt;br /&gt;
   ON a.resourceid = b.resourceid&lt;br /&gt;
LEFT OUTER JOIN v_GS_WORKSTATION_STATUS AS c&lt;br /&gt;
   ON a.resourceid = c.resourceid&lt;br /&gt;
LEFT OUTER JOIN v_AgentDiscoveries e &lt;br /&gt;
   on e.resourceid=a.resourceid&lt;br /&gt;
WHERE a.Name0 IN (SELECT Name0&lt;br /&gt;
                   FROM v_r_system&lt;br /&gt;
                   GROUP BY Name0&lt;br /&gt;
                   HAVING COUNT(*) &lt; 2)
AND (c.LastHWscan is NULL and b.LastScandate is NULL and a.Client0 is NULL)
AND e.AgentTime &gt; getdate()-10&lt;br /&gt;
AND e.AgentName=&#39;SMS_AD_SYSTEM_DISCOVERY_AGENT&#39;)as dt&lt;br /&gt;
where rownum=1&lt;br /&gt;
&lt;br /&gt;
Description: This query will get you all the resources which are having a recent Active directory system discovery date but do not have SMS client agents installed.</content><link rel='replies' type='application/atom+xml' href='http://jj-with-mad-skillz.blogspot.com/feeds/8894258354769813753/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jj-with-mad-skillz.blogspot.com/2010/12/query-to-find-non-sms-clients-with.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4854976060941534129/posts/default/8894258354769813753'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4854976060941534129/posts/default/8894258354769813753'/><link rel='alternate' type='text/html' href='http://jj-with-mad-skillz.blogspot.com/2010/12/query-to-find-non-sms-clients-with.html' title='Query to find non sms clients with recent AD discovery'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/05411953615495526418</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4854976060941534129.post-7796714275192404207</id><published>2010-12-09T07:10:00.000-08:00</published><updated>2010-12-09T08:31:20.570-08:00</updated><title type='text'>SQL Query to find the users logged on to SMS console recently</title><content type='html'>select stat.MachineName as &#39;Accessing the console from&#39;,stat.Sitecode,att1.AttributeValue as &#39;UserName&#39;,att1.AttributeTime as &#39;Loggedin Time&#39;&lt;br /&gt;
FROM vStatusMessages stat &lt;br /&gt;
left join v_StatMsgAttributes as att1 on stat.RecordID = att1.RecordID&lt;br /&gt;
WHERE &lt;br /&gt;
stat.MessageType = 768&lt;br /&gt;
and stat.Sitecode like &#39;%&#39;&lt;br /&gt;
and stat.Time &lt;= getdate()&lt;br /&gt;
and stat.MessageID=30102 &lt;br /&gt;
order by stat.Time desc&lt;br /&gt;
&lt;br /&gt;
Description: This query gives you the list of users who have created a session with SMS console recently.</content><link rel='replies' type='application/atom+xml' href='http://jj-with-mad-skillz.blogspot.com/feeds/7796714275192404207/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jj-with-mad-skillz.blogspot.com/2010/12/sql-query-to-find-users-logged-on-to.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4854976060941534129/posts/default/7796714275192404207'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4854976060941534129/posts/default/7796714275192404207'/><link rel='alternate' type='text/html' href='http://jj-with-mad-skillz.blogspot.com/2010/12/sql-query-to-find-users-logged-on-to.html' title='SQL Query to find the users logged on to SMS console recently'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/05411953615495526418</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4854976060941534129.post-2983380530636001963</id><published>2010-11-29T07:44:00.000-08:00</published><updated>2010-12-01T03:01:59.482-08:00</updated><title type='text'>SMS Report to find last logon user details of computers</title><content type='html'>Select distinct &lt;br /&gt;
v_R_System.Netbios_Name0 AS &quot;Computer Name&quot;,&lt;br /&gt;
v_GS_SYSTEM_CONSOLE_USER.SystemConsoleUser0 AS &quot;Console User&quot;,&lt;br /&gt;
v_GS_SYSTEM_CONSOLE_USER.NumberOfConsoleLogons0 AS &quot;Console Logons&quot;,&lt;br /&gt;
v_GS_SYSTEM_CONSOLE_USER.TotalUserConsoleMinutes0 AS &quot;Total Minutes on Console&quot;,&lt;br /&gt;
v_GS_SYSTEM_CONSOLE_USER.LastConsoleUse0 AS &quot;Last Console Use&quot;&lt;br /&gt;
from v_R_System INNER JOIN&lt;br /&gt;
(SELECT&lt;br /&gt;
ResourceID,&lt;br /&gt;
SystemConsoleUser0,&lt;br /&gt;
NumberOfConsoleLogons0,&lt;br /&gt;
TotalUserConsoleMinutes0,&lt;br /&gt;
LastConsoleUse0,&lt;br /&gt;
ROW_NUMBER() OVER(PARTITION BY ResourceID ORDER BY LastConsoleUse0 DESC) AS Point&lt;br /&gt;
FROM&lt;br /&gt;
v_GS_SYSTEM_CONSOLE_USER) v_GS_SYSTEM_CONSOLE_USER&lt;br /&gt;
ON v_GS_SYSTEM_CONSOLE_USER.ResourceID = v_R_System.ResourceID&lt;br /&gt;
AND v_GS_SYSTEM_CONSOLE_USER.Point = 1&lt;br /&gt;
Order by v_R_System.Netbios_Name0&lt;br /&gt;
&lt;br /&gt;
Description: This will get you the top console user info who logged in to the machines most recently. &lt;br /&gt;
&lt;br /&gt;
Another way to find this is, If you have hardware inventory configured to run on a shorter period, something like it is configured to run daily, get the last logon user info from v_GS_COMPUTER_SYSTEM (This view gets updated with user info every time hardware inventory runs).&lt;br /&gt;
If you have heartbeat discovery running daily, get the last logon user info from v_r_system (This view gets updated with user info every time hearbeat discovery runs).</content><link rel='replies' type='application/atom+xml' href='http://jj-with-mad-skillz.blogspot.com/feeds/2983380530636001963/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jj-with-mad-skillz.blogspot.com/2010/11/sms-report-to-find-last-logon-user.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4854976060941534129/posts/default/2983380530636001963'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4854976060941534129/posts/default/2983380530636001963'/><link rel='alternate' type='text/html' href='http://jj-with-mad-skillz.blogspot.com/2010/11/sms-report-to-find-last-logon-user.html' title='SMS Report to find last logon user details of computers'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/05411953615495526418</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4854976060941534129.post-3881137914889144854</id><published>2010-11-17T04:26:00.000-08:00</published><updated>2010-11-17T04:26:55.179-08:00</updated><title type='text'>SMS report to track SMS site systems with low disk space</title><content type='html'>select SUBSTRING(Sitesystem, CHARINDEX(&#39;\\&#39;, Sitesystem) + 2, CHARINDEX(&#39;&quot;]&#39;, Sitesystem) - CHARINDEX(&#39;\\&#39;, &lt;br /&gt;
Sitesystem) - 3 ) AS siteSystem,&lt;br /&gt;
SiteObject,Sitecode,Role,BytesTotal/1024 as [Total disk space(MB)],BytesFree/1024 as [Free Space(MB)],&lt;br /&gt;
PercentFree as &#39;PercentFreespace&#39;,Downsince&lt;br /&gt;
from v_SiteSystemSummarizer where Role not like &#39;SMS SQL Server&#39; and Percentfree &lt;10</content><link rel='replies' type='application/atom+xml' href='http://jj-with-mad-skillz.blogspot.com/feeds/3881137914889144854/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jj-with-mad-skillz.blogspot.com/2010/11/sms-report-to-track-sms-site-systems.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4854976060941534129/posts/default/3881137914889144854'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4854976060941534129/posts/default/3881137914889144854'/><link rel='alternate' type='text/html' href='http://jj-with-mad-skillz.blogspot.com/2010/11/sms-report-to-track-sms-site-systems.html' title='SMS report to track SMS site systems with low disk space'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/05411953615495526418</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4854976060941534129.post-1304952719395567725</id><published>2010-11-16T03:16:00.001-08:00</published><updated>2010-11-16T03:16:42.376-08:00</updated><title type='text'>WQL query to create a collection with all machines that do not have IE8 installed</title><content type='html'>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_SoftwareFile on SMS_G_System_SoftwareFile.ResourceID = SMS_R_System.ResourceId where SMS_G_System_SoftwareFile.FileName = &quot;iexplore.exe&quot; and SMS_G_System_SoftwareFile.FilePath like &quot;%prog%internet%&quot; and SMS_G_System_SoftwareFile.FileVersion not like &quot;8.%&quot;</content><link rel='replies' type='application/atom+xml' href='http://jj-with-mad-skillz.blogspot.com/feeds/1304952719395567725/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jj-with-mad-skillz.blogspot.com/2010/11/wql-query-to-create-collection-with-all_16.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4854976060941534129/posts/default/1304952719395567725'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4854976060941534129/posts/default/1304952719395567725'/><link rel='alternate' type='text/html' href='http://jj-with-mad-skillz.blogspot.com/2010/11/wql-query-to-create-collection-with-all_16.html' title='WQL query to create a collection with all machines that do not have IE8 installed'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/05411953615495526418</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4854976060941534129.post-8770433241167167389</id><published>2010-11-16T03:11:00.000-08:00</published><updated>2010-11-16T03:11:04.919-08:00</updated><title type='text'>SMS Report to list all machines that do not have IE8 installed</title><content type='html'>select distinct(c.FileDescription +&#39; &#39;+left(c.fileversion,3)) as &#39;Internet Explorer Version&#39;,c.Fileversion as &#39;IE version number&#39;,&lt;br /&gt;
a.Name0 as &#39;Host Name&#39;,a.User_name0 as &#39;User Name&#39;,b.Caption0 + &#39; &#39; + b.CSDVersion0 as &#39;Operating System Version&#39;&lt;br /&gt;
from v_r_system a inner join v_gs_Operating_system b on a.resourceid=b.resourceid&lt;br /&gt;
inner join v_GS_SoftwareFile c on a.resourceid=c.resourceid&lt;br /&gt;
where c.FileName = &#39;iexplore.exe&#39; AND c.FilePath like &#39;%prog%internet%&#39; and c.Fileversion not like &#39;8.%&#39; and (a.client0=1 and a.Obsolete0=0 and a.Active0=1)&lt;br /&gt;
Group By c.FileDescription +&#39; &#39;+left(c.fileversion,3),c.Fileversion,a.Name0,a.User_name0,b.Caption0 + &#39; &#39; + b.CSDVersion0&lt;br /&gt;
ORDER BY c.FileDescription +&#39; &#39;+left(c.fileversion,3)</content><link rel='replies' type='application/atom+xml' href='http://jj-with-mad-skillz.blogspot.com/feeds/8770433241167167389/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jj-with-mad-skillz.blogspot.com/2010/11/sms-report-to-list-all-machines-that-do.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4854976060941534129/posts/default/8770433241167167389'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4854976060941534129/posts/default/8770433241167167389'/><link rel='alternate' type='text/html' href='http://jj-with-mad-skillz.blogspot.com/2010/11/sms-report-to-list-all-machines-that-do.html' title='SMS Report to list all machines that do not have IE8 installed'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/05411953615495526418</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4854976060941534129.post-4615747339094237893</id><published>2010-11-09T22:01:00.002-08:00</published><updated>2010-11-09T22:01:36.308-08:00</updated><title type='text'>WQL query to create a collection with all Desktops</title><content type='html'>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_SYSTEM_ENCLOSURE on SMS_G_System_SYSTEM_ENCLOSURE.ResourceID = SMS_R_System.ResourceId where SMS_G_System_SYSTEM_ENCLOSURE.ChassisTypes in ( &quot;1&quot;, &quot;2&quot;, &quot;3&quot;, &quot;4&quot;, &quot;5&quot;, &quot;6&quot;, &quot;7&quot;, &quot;15&quot; ) and SMS_R_System.Client = 1 and SMS_R_System.Obsolete = 0 and SMS_R_System.Active = 1</content><link rel='replies' type='application/atom+xml' href='http://jj-with-mad-skillz.blogspot.com/feeds/4615747339094237893/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jj-with-mad-skillz.blogspot.com/2010/11/wql-query-to-create-collection-with-all_09.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4854976060941534129/posts/default/4615747339094237893'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4854976060941534129/posts/default/4615747339094237893'/><link rel='alternate' type='text/html' href='http://jj-with-mad-skillz.blogspot.com/2010/11/wql-query-to-create-collection-with-all_09.html' title='WQL query to create a collection with all Desktops'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/05411953615495526418</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4854976060941534129.post-3486369720791345908</id><published>2010-11-09T22:01:00.000-08:00</published><updated>2010-11-09T22:01:00.055-08:00</updated><title type='text'>WQL query to create a collection with all laptops</title><content type='html'>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_SYSTEM_ENCLOSURE on SMS_G_System_SYSTEM_ENCLOSURE.ResourceID = SMS_R_System.ResourceId where SMS_G_System_SYSTEM_ENCLOSURE.ChassisTypes in ( &quot;8&quot;, &quot;10&quot;, &quot;12&quot;, &quot;14&quot;, &quot;18&quot;, &quot;21&quot; ) and SMS_R_System.Client = 1 and SMS_R_System.Obsolete = 0 and SMS_R_System.Active = 1</content><link rel='replies' type='application/atom+xml' href='http://jj-with-mad-skillz.blogspot.com/feeds/3486369720791345908/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jj-with-mad-skillz.blogspot.com/2010/11/wql-query-to-create-collection-with-all.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4854976060941534129/posts/default/3486369720791345908'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4854976060941534129/posts/default/3486369720791345908'/><link rel='alternate' type='text/html' href='http://jj-with-mad-skillz.blogspot.com/2010/11/wql-query-to-create-collection-with-all.html' title='WQL query to create a collection with all laptops'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/05411953615495526418</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4854976060941534129.post-3095609853524273339</id><published>2010-10-28T04:00:00.001-07:00</published><updated>2010-10-28T04:00:46.357-07:00</updated><title type='text'>Query to get  detailed summary of all the advertisments</title><content type='html'>SELECT a.Netbios_name0 as &#39;Host Name&#39;,&lt;br /&gt;
site.sms_installed_sites0 as &#39;Sitecode&#39;,&lt;br /&gt;
a.Client0,&lt;br /&gt;
a.Obsolete0,&lt;br /&gt;
adv.AdvertisementName,&lt;br /&gt;
adv.AdvertisementID,&lt;br /&gt;
adv.Comment as &#39;Description&#39;,&lt;br /&gt;
pkg.Name AS &#39;Package Name&#39;,&lt;br /&gt;
adv.ProgramName,&lt;br /&gt;
col.Name as &#39;Collection Name&#39;,&lt;br /&gt;
adv.CollectionID,&lt;br /&gt;
advstate.LastAcceptanceMessageIDname,&lt;br /&gt;
advstate.LastAcceptanceStateName,&lt;br /&gt;
advstate.LastAcceptanceStatusTime,&lt;br /&gt;
advstate.LastStatusmessageIDName,&lt;br /&gt;
advstate.LaststateName,&lt;br /&gt;
advstate.LastStatusTime,&lt;br /&gt;
advstate.LastExecutionResult,&lt;br /&gt;
advstate.LastExecutionContext&lt;br /&gt;
FROM v_Advertisement adv&lt;br /&gt;
INNER JOIN v_Package pkg ON adv.PackageID = pkg.PackageID&lt;br /&gt;
INNER JOIN V_COLLECTION col ON adv.CollectionID=col.CollectionID&lt;br /&gt;
INNER JOIN v_ClientAdvertisementStatus advstate on adv.AdvertisementID=advstate.AdvertisementID&lt;br /&gt;
INNER JOIN V_R_SYSTEM a ON a.Resourceid=advstate.resourceid&lt;br /&gt;
INNER JOIN v_GS_WORKSTATION_STATUS HW ON a.resourceid=hw.resourceid&lt;br /&gt;
INNER JOIN v_GS_LastSoftwareScan sw ON a.resourceid=sw.resourceid&lt;br /&gt;
LEFT OUTER JOIN v_RA_System_SMSInstalledSites site ON a.resourceid=site.resourceid&lt;br /&gt;
WHERE adv.AdvertisementID LIKE &#39;%&#39;&lt;br /&gt;
order by adv.AdvertisementName</content><link rel='replies' type='application/atom+xml' href='http://jj-with-mad-skillz.blogspot.com/feeds/3095609853524273339/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jj-with-mad-skillz.blogspot.com/2010/10/query-to-get-detailed-summary-of-all.html#comment-form' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4854976060941534129/posts/default/3095609853524273339'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4854976060941534129/posts/default/3095609853524273339'/><link rel='alternate' type='text/html' href='http://jj-with-mad-skillz.blogspot.com/2010/10/query-to-get-detailed-summary-of-all.html' title='Query to get  detailed summary of all the advertisments'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/05411953615495526418</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4854976060941534129.post-7008949799645651412</id><published>2010-10-25T09:45:00.000-07:00</published><updated>2010-11-04T06:22:55.732-07:00</updated><title type='text'>SQL Query to find duplicates from siamese twins machines!!</title><content type='html'>SELECT &lt;br /&gt;
[Name0],&lt;br /&gt;
[resourceid],&lt;br /&gt;
[Obsolete],&lt;br /&gt;
[Client],&lt;br /&gt;
[LastSWscan],&lt;br /&gt;
[LastHWscan]&lt;br /&gt;
FROM &lt;br /&gt;
(&lt;br /&gt;
select &lt;br /&gt;
row_number() over (partition by a.Name0 order by c.Lasthwscan desc) as rownum,&lt;br /&gt;
a.Name0 as [Name0],&lt;br /&gt;
a.resourceid as [resourceid],&lt;br /&gt;
a.Obsolete0 as [Obsolete],&lt;br /&gt;
a.Client0 as [Client],&lt;br /&gt;
b.Lastscandate as [LastSWscan],&lt;br /&gt;
c.Lasthwscan as [Lasthwscan]&lt;br /&gt;
&lt;br /&gt;
from v_r_system AS a&lt;br /&gt;
LEFT OUTER JOIN v_GS_LastSoftwareScan AS b&lt;br /&gt;
ON a.resourceid = b.resourceid&lt;br /&gt;
LEFT OUTER JOIN v_GS_WORKSTATION_STATUS AS c&lt;br /&gt;
ON a.resourceid = c.resourceid&lt;br /&gt;
WHERE a.Name0 IN (SELECT Name0&lt;br /&gt;
FROM v_r_system&lt;br /&gt;
GROUP BY Name0&lt;br /&gt;
HAVING COUNT(*) &gt; 1)&lt;br /&gt;
AND (c.LastHWscan is NOT NULL and b.LastScandate is NOT NULL and a.Client0=1 and a.Obsolete0=0 and a.Active0=1)) as dt&lt;br /&gt;
where rownum&lt;&gt;1&lt;br /&gt;
order by [Lasthwscan] desc&lt;br /&gt;
&lt;br /&gt;
Description: Obsolete machines are common in all the SMS\SCCM environments. This can be easily tracked and maintained by checking the Obsolete flag from the v_r_system view. But what if you have more than one entry with the same hostname which is active non Obsolete and client=1 and with recent hardware\software and discovery information&#39;s?...It is sometimes very tough to differentiate the real one from the duplicate. The above query is written to overcome this issue. The query lists all those boxes which have an older hardware scan time compare to it&#39;s twin machine.(and 99% of times, this gives you the correct value).&lt;br /&gt;
&lt;br /&gt;
To double check, take random number of hostnames from the above query result, and provide in the where condition of below query...&lt;br /&gt;
&lt;br /&gt;
select a.Netbios_name0, a.resourceid,a.Creation_date0,a.client0, a.ad_site_name0,a.Creation_date0,a.obsolete0,&lt;br /&gt;
b.sms_installed_sites0 as &#39;sitecode&#39;,c.Lasthwscan,d.Agenttime&lt;br /&gt;
from v_r_system a&lt;br /&gt;
left outer join v_RA_System_SMSInstalledSites b on a.resourceid=b.resourceid&lt;br /&gt;
left outer join v_GS_WORKSTATION_STATUS c on a.resourceid=c.resourceid&lt;br /&gt;
Left outer join v_AgentDiscoveries d on d.resourceid=a.resourceid&lt;br /&gt;
where a.Netbios_name0 like &#39;machinenamehere&#39; and d.AgentName=&#39;Heartbeat Discovery&#39;</content><link rel='replies' type='application/atom+xml' href='http://jj-with-mad-skillz.blogspot.com/feeds/7008949799645651412/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jj-with-mad-skillz.blogspot.com/2010/10/sql-query-to-find-duplicates-from.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4854976060941534129/posts/default/7008949799645651412'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4854976060941534129/posts/default/7008949799645651412'/><link rel='alternate' type='text/html' href='http://jj-with-mad-skillz.blogspot.com/2010/10/sql-query-to-find-duplicates-from.html' title='SQL Query to find duplicates from siamese twins machines!!'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/05411953615495526418</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4854976060941534129.post-6012316972104784512</id><published>2010-10-21T03:51:00.000-07:00</published><updated>2010-10-21T03:51:38.101-07:00</updated><title type='text'>Query to find Installed Application list from all machines</title><content type='html'>select distinct (a.Netbios_name0), a.Creation_date0,a.User_name0,a.ad_site_name0,b.sms_installed_sites0 as &#39;sitecode&#39;,&lt;br /&gt;
os.Caption0 + &#39; &#39;+ os.CSDversion0 as &#39;Operating System&#39;,addr.DisplayName0,addr.Version0,addr.Publisher0,addr.InstallDate0&lt;br /&gt;
from v_r_system a&lt;br /&gt;
left outer join v_RA_System_SMSInstalledSites b on a.resourceid=b.resourceid&lt;br /&gt;
left outer join v_GS_WORKSTATION_STATUS c on a.resourceid=c.resourceid&lt;br /&gt;
left outer join v_GS_Operating_system OS on os.resourceid=a.resourceid&lt;br /&gt;
inner join v_GS_ADD_REMOVE_PROGRAMS addr on addr.resourceid=a.resourceid&lt;br /&gt;
where addr.DisplayName0 not like &#39;%kb%&#39;&lt;br /&gt;
and (a.Client0=1 and a.Obsolete0=0 and a.Active0=1)&lt;br /&gt;
order by a.Netbios_name0,addr.Publisher0</content><link rel='replies' type='application/atom+xml' href='http://jj-with-mad-skillz.blogspot.com/feeds/6012316972104784512/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jj-with-mad-skillz.blogspot.com/2010/10/query-to-find-installed-application.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4854976060941534129/posts/default/6012316972104784512'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4854976060941534129/posts/default/6012316972104784512'/><link rel='alternate' type='text/html' href='http://jj-with-mad-skillz.blogspot.com/2010/10/query-to-find-installed-application.html' title='Query to find Installed Application list from all machines'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/05411953615495526418</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4854976060941534129.post-1579380543712761211</id><published>2010-10-14T07:04:00.000-07:00</published><updated>2010-10-14T07:04:42.524-07:00</updated><title type='text'>WQL query to find machines with IE version 7</title><content type='html'>select distinct SMS_G_System_SoftwareFile.FileDescription, SMS_G_System_SoftwareFile.FileVersion,SMS_G_System_SYSTEM.Name, &lt;br /&gt;
SMS_G_System_OPERATING_SYSTEM.Caption from  SMS_R_System inner join SMS_G_System_SoftwareFile on &lt;br /&gt;
SMS_G_System_SoftwareFile.ResourceID = SMS_R_System.ResourceId inner join SMS_G_System_SYSTEM on &lt;br /&gt;
SMS_G_System_SYSTEM.ResourceID = SMS_R_System.ResourceId inner join SMS_G_System_OPERATING_SYSTEM on &lt;br /&gt;
SMS_G_System_OPERATING_SYSTEM.ResourceID = SMS_R_System.ResourceId WHERE &lt;br /&gt;
SMS_G_System_SoftwareFile.FileName = &quot;iexplore.exe&quot; AND SMS_G_System_SoftwareFile.FilePath like &quot;%prog%internet%&quot; &lt;br /&gt;
and SMS_G_System_SoftwareFile.Fileversion like &quot;7.%&quot;</content><link rel='replies' type='application/atom+xml' href='http://jj-with-mad-skillz.blogspot.com/feeds/1579380543712761211/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jj-with-mad-skillz.blogspot.com/2010/10/wql-query-to-find-machines-with-ie.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4854976060941534129/posts/default/1579380543712761211'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4854976060941534129/posts/default/1579380543712761211'/><link rel='alternate' type='text/html' href='http://jj-with-mad-skillz.blogspot.com/2010/10/wql-query-to-find-machines-with-ie.html' title='WQL query to find machines with IE version 7'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/05411953615495526418</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4854976060941534129.post-157521260954129060</id><published>2010-10-14T03:22:00.000-07:00</published><updated>2010-10-14T03:30:58.320-07:00</updated><title type='text'>Query to find all machines with Internet Explorer 7 version</title><content type='html'>select distinct(c.FileDescription +&#39; &#39;+left(c.fileversion,3)) as &#39;Internet Explorer Version&#39;,c.Fileversion as &#39;IE version number&#39;,&lt;br /&gt;
 a.Name0 as &#39;Host Name&#39;,a.User_name0 as &#39;User Name&#39;,b.Caption0 + &#39; &#39; + b.CSDVersion0 as &#39;Operating System Version&#39;&lt;br /&gt;
from v_r_system a inner join v_gs_Operating_system b on a.resourceid=b.resourceid&lt;br /&gt;
inner join v_GS_SoftwareFile c on a.resourceid=c.resourceid&lt;br /&gt;
where c.FileName = &#39;iexplore.exe&#39; AND c.FilePath like &#39;%prog%internet%&#39; and c.Fileversion like &#39;7.%&#39; and (a.client0=1 and a.Obsolete0=0 and a.Active0=1)&lt;br /&gt;
Group By c.FileDescription +&#39; &#39;+left(c.fileversion,3),c.Fileversion,a.Name0,a.User_name0,b.Caption0 + &#39; &#39; + b.CSDVersion0 &lt;br /&gt;
ORDER BY c.FileDescription +&#39; &#39;+left(c.fileversion,3)</content><link rel='replies' type='application/atom+xml' href='http://jj-with-mad-skillz.blogspot.com/feeds/157521260954129060/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jj-with-mad-skillz.blogspot.com/2010/10/query-to-find-all-machines-with.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4854976060941534129/posts/default/157521260954129060'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4854976060941534129/posts/default/157521260954129060'/><link rel='alternate' type='text/html' href='http://jj-with-mad-skillz.blogspot.com/2010/10/query-to-find-all-machines-with.html' title='Query to find all machines with Internet Explorer 7 version'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/05411953615495526418</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4854976060941534129.post-6143792179502078228</id><published>2010-10-08T06:18:00.000-07:00</published><updated>2010-10-08T06:18:24.928-07:00</updated><title type='text'>Query to find the workstations thrown access denied against a client installation attempt</title><content type='html'>select InsStrValue, [time], [Site Code], [Site Server], Win32Error&lt;br /&gt;
from&lt;br /&gt;
(&lt;br /&gt;
 select &lt;br /&gt;
 row_number() over (partition by ins.InsStrValue order by stat.[time] desc) as rownum,&lt;br /&gt;
 ins.InsStrValue,&lt;br /&gt;
 stat.[time],&lt;br /&gt;
 stat.Sitecode as [Site Code], &lt;br /&gt;
 stat.MachineName as [Site Server],&lt;br /&gt;
 stat.Win32Error&lt;br /&gt;
 from v_StatusMessage as stat &lt;br /&gt;
 left join v_StatMsgInsStrings as ins &lt;br /&gt;
    on stat.RecordID = ins.RecordID&lt;br /&gt;
&lt;br /&gt;
 where stat.Component = &#39;SMS_CLIENT_CONFIG_MANAGER&#39; &lt;br /&gt;
  and stat.Win32Error = &#39;5&#39;&lt;br /&gt;
) as dt&lt;br /&gt;
where rownum=1&lt;br /&gt;
order by [time] desc&lt;br /&gt;
&lt;br /&gt;
Description: This query will list you all the machines which have thrown an access denied error against client installation attempts etc.. This query will work only if you have SQL 2005 or above as your SMS DB.</content><link rel='replies' type='application/atom+xml' href='http://jj-with-mad-skillz.blogspot.com/feeds/6143792179502078228/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jj-with-mad-skillz.blogspot.com/2010/10/query-to-find-workstations-thrown.html#comment-form' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4854976060941534129/posts/default/6143792179502078228'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4854976060941534129/posts/default/6143792179502078228'/><link rel='alternate' type='text/html' href='http://jj-with-mad-skillz.blogspot.com/2010/10/query-to-find-workstations-thrown.html' title='Query to find the workstations thrown access denied against a client installation attempt'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/05411953615495526418</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4854976060941534129.post-300139650263645732</id><published>2010-10-04T11:24:00.001-07:00</published><updated>2010-10-04T11:26:47.211-07:00</updated><title type='text'>Query to list machines with their MS Office versions</title><content type='html'>select distinct (a.Netbios_name0), a.Creation_date0,a.User_name0,a.client0, a.ad_site_name0,a.obsolete0,b.sms_installed_sites0 as &#39;sitecode&#39;,&lt;br /&gt;
os.Caption0 + &#39; &#39;+ os.CSDversion0 as &#39;Operating System&#39;,addr.DisplayName0,addr.Version0,addr.Publisher0,addr.InstallDate0&lt;br /&gt;
from v_r_system a&lt;br /&gt;
left outer join v_RA_System_SMSInstalledSites b on a.resourceid=b.resourceid&lt;br /&gt;
left outer join v_GS_WORKSTATION_STATUS c on a.resourceid=c.resourceid&lt;br /&gt;
left outer join v_GS_Operating_system OS on os.resourceid=a.resourceid&lt;br /&gt;
inner join v_GS_ADD_REMOVE_PROGRAMS addr on addr.resourceid=a.resourceid&lt;br /&gt;
where addr.DisplayName0 like &#39;Microsoft Office 2%&#39;</content><link rel='replies' type='application/atom+xml' href='http://jj-with-mad-skillz.blogspot.com/feeds/300139650263645732/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jj-with-mad-skillz.blogspot.com/2010/10/query-to-list-machines-with-their-ms.html#comment-form' title='5 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4854976060941534129/posts/default/300139650263645732'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4854976060941534129/posts/default/300139650263645732'/><link rel='alternate' type='text/html' href='http://jj-with-mad-skillz.blogspot.com/2010/10/query-to-list-machines-with-their-ms.html' title='Query to list machines with their MS Office versions'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/05411953615495526418</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>5</thr:total></entry></feed>