Monday, November 29, 2010

SMS Report to find last logon user details of computers

Select distinct
v_R_System.Netbios_Name0 AS "Computer Name",
v_GS_SYSTEM_CONSOLE_USER.SystemConsoleUser0 AS "Console User",
v_GS_SYSTEM_CONSOLE_USER.NumberOfConsoleLogons0 AS "Console Logons",
v_GS_SYSTEM_CONSOLE_USER.TotalUserConsoleMinutes0 AS "Total Minutes on Console",
v_GS_SYSTEM_CONSOLE_USER.LastConsoleUse0 AS "Last Console Use"
from v_R_System INNER JOIN
(SELECT
ResourceID,
SystemConsoleUser0,
NumberOfConsoleLogons0,
TotalUserConsoleMinutes0,
LastConsoleUse0,
ROW_NUMBER() OVER(PARTITION BY ResourceID ORDER BY LastConsoleUse0 DESC) AS Point
FROM
v_GS_SYSTEM_CONSOLE_USER) v_GS_SYSTEM_CONSOLE_USER
ON v_GS_SYSTEM_CONSOLE_USER.ResourceID = v_R_System.ResourceID
AND v_GS_SYSTEM_CONSOLE_USER.Point = 1
Order by v_R_System.Netbios_Name0

Description: This will get you the top console user info who logged in to the machines most recently.

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).
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).

Wednesday, November 17, 2010

SMS report to track SMS site systems with low disk space

select SUBSTRING(Sitesystem, CHARINDEX('\\', Sitesystem) + 2, CHARINDEX('"]', Sitesystem) - CHARINDEX('\\',
Sitesystem) - 3 ) AS siteSystem,
SiteObject,Sitecode,Role,BytesTotal/1024 as [Total disk space(MB)],BytesFree/1024 as [Free Space(MB)],
PercentFree as 'PercentFreespace',Downsince
from v_SiteSystemSummarizer where Role not like 'SMS SQL Server' and Percentfree <10

Tuesday, November 16, 2010

WQL query to create a collection with all machines that do not have IE8 installed

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 = "iexplore.exe" and SMS_G_System_SoftwareFile.FilePath like "%prog%internet%" and SMS_G_System_SoftwareFile.FileVersion not like "8.%"

SMS Report to list all machines that do not have IE8 installed

select distinct(c.FileDescription +' '+left(c.fileversion,3)) as 'Internet Explorer Version',c.Fileversion as 'IE version number',
a.Name0 as 'Host Name',a.User_name0 as 'User Name',b.Caption0 + ' ' + b.CSDVersion0 as 'Operating System Version'
from v_r_system a inner join v_gs_Operating_system b on a.resourceid=b.resourceid
inner join v_GS_SoftwareFile c on a.resourceid=c.resourceid
where c.FileName = 'iexplore.exe' AND c.FilePath like '%prog%internet%' and c.Fileversion not like '8.%' and (a.client0=1 and a.Obsolete0=0 and a.Active0=1)
Group By c.FileDescription +' '+left(c.fileversion,3),c.Fileversion,a.Name0,a.User_name0,b.Caption0 + ' ' + b.CSDVersion0
ORDER BY c.FileDescription +' '+left(c.fileversion,3)

Tuesday, November 9, 2010

WQL query to create a collection with all Desktops

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 ( "1", "2", "3", "4", "5", "6", "7", "15" ) and SMS_R_System.Client = 1 and SMS_R_System.Obsolete = 0 and SMS_R_System.Active = 1

WQL query to create a collection with all laptops

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 ( "8", "10", "12", "14", "18", "21" ) and SMS_R_System.Client = 1 and SMS_R_System.Obsolete = 0 and SMS_R_System.Active = 1