generate the list of all systems that are lower than 1909


Hi Team, I need to generate the list of all systems that are lower than 1909 version and have space issue machines report. Can one help me with query.

solved 0
Venkat 4 months 4 Answers 279 views Beginner 0

Answers ( 4 )

  1. Also avoid duplicate questions venkat p ?

  2. Hello Venkat – Can you please spend some time in typing the title appropriately … rather than just putting your entire question in the title itself .

  3. Hi,

    Use below SQL Query:
    Select distinct
    Vrs.name0 as ‘MachineName’,
    Vos.Caption0 as ‘Operating System(HW)’,
    case when cdr.IsClient =1 then ‘Yes’ else ‘No’ end as ‘SCCMClient Status’,
    Vcc.ClientStateDescription as ‘SCCMHealth Status’,
    WSLN.Value as ‘Build Version’,
    Vos.CSDVersion0 as ‘Service Pack’,
    Vos.Version0 as ‘OS Version’,
    Vcs.SystemType0 as ‘OS Type’,
    WHEN Vse.ChassisTypes0 in (‘1’) THEN ‘Virtual’
    WHEN Vse.ChassisTypes0 in (‘8′,’9′,’10’,’12’,’14’,’11’,’17’,’31’,’32’) THEN ‘Laptop’
    WHEN Vse.ChassisTypes0 in (‘2′,’3′,’4′,’5′,’6′,’7′,’13’,’15’,’16’,’35’) THEN ‘Desktop’
    WHEN Vse.ChassisTypes0 in (’23’) THEN ‘RackMount’
    when Vse.ChassisTypes0 is Null Then ‘NA’
    Else ‘Others’ END as ‘ChassisType’,
    Vcs.Manufacturer0 as ‘Manufacturer’,
    CASE WHEN CAST(Vcs.Manufacturer0 as NVarchar(255)) LIKE ‘%LENOVO%’
    THEN CAST(Vcsp.Version0 as NVarchar(255)) ELSE CAST(Vcs.Model0 as NVarchar(255)) END AS ‘Model’,
    cdr.MACAddress as ‘MACAddress’,
    Seu.SerialNumber0 as ‘SerialNumber’,
    Vse.SMBIOSAssetTag0 as ‘AssetTag’,
    convert(varchar,VPM.TOTALPHYSICALMEMORY0 / (1024)/1000 ) as ‘Total_RAM_Size_GB’,
    (select sum(Size0)/1024 from v_GS_LOGICAL_DISK where ResourceID = vrs.ResourceID) as ‘Total_HDD_Size_GB’,
    (select min(Freespace0)/1024 from v_GS_LOGICAL_DISK where ResourceID = vrs.ResourceID) as ‘Total_Free_Size_GB’,
    case when cdr.clientstate=0 then ‘No Pending Reboot’ else ‘Pending Reboot’ end as ‘Reboot Status’,
    case when cdr.cnisonline=1 then ‘Online’ else ‘Offline’ end as ‘Current Online Status’,
    Cdr.ClientVersion as ‘SCCM Version’,
    Cdr.cnlastonlinetime as ‘Last Online Status’,
    Cdr.lastpolicyrequest as ‘Last Policy Request’,
    cdr.LastDDR as ‘Last Heartbeat Scan’,
    Cdr.LastHardwareScan as ‘Last HW Scan’,
    cdr.LastSoftwareScan as ‘Last SW Scan’,
    Vus.LastScanTime as ‘Last SUP Scan’,
    Vus.lasterrorcode as ‘LastSUPScanStatus’,
    Vus.lastscanpackagelocation as ‘SUPLocationPath’,
    cdr.LastMPServerName as ‘LastMPServerName’,
    cdr.LastStatusMessage as ‘Last Status Msg’,
    (select MAX(AgentTime) from v_AgentDiscoveries where AgentName = ‘SMS_AD_SYSTEM_DISCOVERY_AGENT’ and ResourceID = Vrs.ResourceID) as ‘Last AD SysDisc Scan’,
    cdr.ADLastLogonTime as ‘Last AD Logon Stamp’,
    DateDiff(D, Convert(VarChar, Cdr.cnlastonlinetime,100), GetDate()) as ‘Last Online Status(Days)’,
    DateDiff(D, Convert(VarChar, Cdr.lastpolicyrequest,100), GetDate()) as ‘Last Policy Request(Days)’,
    DateDiff(D, Convert(VarChar, Cdr.LastDDR,100), GetDate()) as ‘Last Heartbeat Scan(Days)’,
    DateDiff(D, Convert(VarChar, Cdr.LastHardwareScan,100), GetDate()) as ‘Last HW Scan(Days)’,
    DateDiff(D, Convert(VarChar, Cdr.LastSoftwareScan,100), GetDate()) as ‘Last SW Scan(Days)’,
    DateDiff(D, Convert(VarChar, Vus.LastScanTime,100), GetDate()) as ‘Last SUP Scan(Days)’,
    DateDiff(D, Convert(VarChar, (select MAX(AgentTime) from v_AgentDiscoveries where AgentName = ‘SMS_AD_SYSTEM_DISCOVERY_AGENT’ and ResourceID = Vrs.ResourceID),100), GetDate()) as ‘Last AD SysDisc Scan (Days)’,
    DateDiff(D, Convert(VarChar, cdr.ADLastLogonTime,100), GetDate()) as ‘Last ADLogon Stamp (Days)’,
    FORMAT(Vos.InstallDate0, ‘MM/dd/yyyy HH:mm:ss’) as ‘OS Install Date’,
    DateDiff(D, Vos.InstallDate0, GetDate()) ‘OS Install Date (Days)’,
    FORMAT(Vos.LastBootUpTime0, ‘MM/dd/yyyy HH:mm:ss’) as ‘LastBootUpDate’,
    DateDiff(D, Convert(VarChar, Vos.LastBootUpTime0,100), GetDate()) as ‘Last BootUp Date (Days)’,
    (select max(v_GS_VIDEO_CONTROLLER.Name0) as ‘VideocardDriverversion’ from v_GS_VIDEO_CONTROLLER where ResourceID = vrs.ResourceID) as ‘VideoCardName’,
    (select max(v_GS_NETWORK_ADAPTER.Name0) from v_GS_NETWORK_ADAPTER where Description0 like ‘%Wireless%’ and ResourceID = vrs.ResourceID) as ‘WirelessAdpater’,
    (select max(v_GS_NETWORK_ADAPTER.Name0) from v_GS_NETWORK_ADAPTER where Description0 like ‘%Ethernet Connection%’ and ResourceID = vrs.ResourceID) as ‘LANAdpater’,
    Tpm.PhysicalPresenceVersionInfo0 as ‘TPMVersion’,
    Vpb.Name0 as ‘BiosName’,
    Vpb.BIOSVersion0 as ‘BiosVersion’,
    Vp.Name0 as ‘ProcessorName’,
    Vp.NumberOfCores0 as ‘NumberOfCores’,
    Vp.NumberOfLogicalProcessors0 as ‘NumberOfLogicalProcessors’,
    Vra.SMS_Assigned_Sites0 as ‘AssignedSite’,
    cdr.ADSiteName as ‘ADSiteName’,
    Vrs.Full_Domain_Name0 as ‘FullDomainName’,
    (Vrs.Name0 + ‘.’ + Vrs.Full_Domain_Name0) as ‘FQDN’,
    Vrs.USER_DOMAIN0 as ‘UserDomain’,
    Vrs.USER_NAME0 as ‘LastLogonID’,
    Vcud.TOPCONSOLEUSER00 as ‘TopConsoleUserID’,
    END as ‘LogonID’,
    Vru.Mail0 as ‘EMailID’
    FROM v_R_System as Vrs
    LEFT JOIN V_GS_PC_BIOS as Vpb ON Vpb.ResourceID = Vrs.ResourceID
    LEFT JOIN V_GS_X86_PC_MEMORY as Vpm ON VPM.ResourceID = Vrs.ResourceID
    LEFT JOIN V_GS_COMPUTER_SYSTEM as Vcs ON VCS.ResourceID = Vrs.ResourceID
    LEFT JOIN V_GS_TPM as Tpm ON tpm.ResourceID = Vrs.ResourceID
    LEFT JOIN SYSTEM_CONSOLE_USAGE_DATA as Vcud ON Vcud.MachineID = Vrs.ResourceID
    LEFT JOIN V_GS_SYSTEM_ENCLOSURE as Vse ON Vse.ResourceID = Vrs.ResourceID
    LEFT JOIN V_GS_OPERATING_SYSTEM as Vos ON Vos.ResourceID = Vrs.ResourceID
    LEFT JOIN v_UpdateScanStatus as Vus ON Vus.ResourceID = Vrs.ResourceID
    LEFT JOIN V_GS_LOGICAL_DISK as Vgl ON Vgl.ResourceID = Vrs.ResourceID
    LEFT JOIN V_GS_PROCESSOR as Vp ON Vp.ResourceID = Vrs.ResourceID
    LEFT JOIN v_RA_System_SMSAssignedSites as Vra ON Vra.ResourceID = VRS.ResourceID
    LEFT JOIN v_R_User as Vru ON Vru.User_Name0 = Vrs.User_Name0
    LEFT JOIN fn_GetWindowsServicingStates() as WSS on WSS.Build = Vos.Version0 and WSS.Branch = Vrs.OSBranch01
    LEFT JOIN fn_GetWindowsServicingLocalizedNames() as WSLN On WSS.Name = WSLN.Name
    LEFT JOIN System_MAC_Addres_ARR as Mac ON Mac.ItemKey = Vrs.ResourceID
    LEFT JOIN V_GS_INSTALLED_SOFTWARE as App ON App.ResourceID = Vrs.ResourceID
    LEFT JOIN V_CombinedDeviceResources as Cdr ON Cdr.MachineID = Vrs.ResourceID
    LEFT JOIN v_CH_ClientSummary as Vcc ON Vcc.ResourceID = Vrs.ResourceID
    LEFT JOIN v_GS_VIDEO_CONTROLLER as Vvc ON Vvc.ResourceID = Vrs.ResourceId
    INNER JOIN V_FullCollectionMembership_Valid as Col ON Col.ResourceID = Vrs.ResourceID
    WHERE Col.CollectionID = ‘SMS00001’
    and Vrs.Active0 = 1 and Vrs.Obsolete0 = 0 and Vrs.Decommissioned0 = 0
    and WSLN.Value not like ‘1909’ — Not like 1909 version
    and (Vgl.FreeSpace0)/1024 < '10' — less than FreeSpace 10 GB
    order by vrs.name0


    Best answer

Leave an answer

Sorry, you do not have a permission to answer to this question .