‎02-17-2022 08:19 PM
‎02-17-2022 10:39 PM
Select Top 1000000 tblAssets.AssetID,
tblAssets.AssetName,
tsysAssetTypes.AssetTypename As [Asset Type],
tblstate.State,
tblstate.Statename,
tsysOS.Image As icon,
tsysOS.OSname As [OS name],
tsysOS.OSCodeNumeric As OS,
tblAssets.OScode As [OS Build],
Case
When tblAssetCustom.Manufacturer Like '%lenovo%' Then
tblComputerSystemProduct.Version
Else tblAssetCustom.Model
End As Model,
tblAssetCustom.Serialnumber,
tblAssets.Username,
tblAssets.IPAddress,
tblAssetCustom.Location As CustomLocation,
tsysIPLocations.IPLocation,
tblADComputers.Location As ADlocation,
tblAssets.Domain,
tblAssets.Firstseen,
tblAssets.Lastseen,
tblAssets.Lasttried,
tblAntivirus.DisplayName As AntiVirus,
tblAntivirus.ProductState As [AV State],
tblAntivirus.onAccessScanningEnabled As [AV Enabled],
tblAssetCustom.PurchaseDate As [Purchase Date],
tblAssetCustom.Warrantydate As [Warranty Expiration],
tblSccmAsset.LastScanDate As [SCCM Last Scan]
From tblAssets
Inner Join tblAssetCustom On tblAssets.AssetID = tblAssetCustom.AssetID
Inner Join tsysOS On tsysOS.OScode = tblAssets.OScode
Left Join tblADComputers On tblAssets.AssetID = tblADComputers.AssetID
Left Join tblSccmAsset On tblAssets.AssetID = tblSccmAsset.AssetId
Left Outer Join tsysIPLocations On tblAssets.IPNumeric >=
tsysIPLocations.StartIP And tblAssets.IPNumeric <= tsysIPLocations.EndIP
Inner Join tblstate On tblstate.State = tblAssetCustom.State
Inner Join tblAntivirus On tblAssets.AssetID = tblAntivirus.AssetID
Inner Join tblComputerSystem On tblAssets.AssetID = tblComputerSystem.AssetID
Inner Join tblDomainroles On tblComputerSystem.Domainrole =
tblDomainroles.Domainrole
Inner Join tblComputerSystemProduct On tblAssets.AssetID =
tblComputerSystemProduct.AssetID
Inner Join tsysAssetTypes On tblAssets.Assettype = tsysAssetTypes.AssetType
Where tblAssets.AssetID Not In (Select Distinct tblAntivirus.AssetID
From tblAntivirus Where (Case
When tblAntivirus.onAccessScanningEnabled <> 0 Then
'Antivirus Enabled or Unknown'
End) = 'Antivirus Enabled or Unknown') And tblstate.Statename = 'Active'
And ((tblAssetCustom.PurchaseDate Is Not Null And tblAssetCustom.State = 1) Or
(tblAssetCustom.Warrantydate Is Not Null And tblAssetCustom.State = 1)) And
((tblSccmAsset.AssetId Is Null) Or (tblAssets.ScannedBy = 2)) And
tblDomainroles.Domainrolename In ('Stand-alone Workstation',
'Member Workstation')
Order By tblAssets.AssetName
Experience Lansweeper with your own data. Sign up now for a 14-day free trial.
Try Now