→ 🚀What's New? Join Us for the Fall Product Launch! Register Now !
‎11-05-2013 02:09 PM
Solved! Go to Solution.
‎11-05-2013 07:13 PM
SELECT Top 1000000
tblAssets.AssetID,
tblAssets.AssetName,
tsysAssetTypes.AssetTypename,
tsysAssetTypes.AssetTypeIcon10 As icon,
tblAssets.Domain,
tbldomainroles.Domainrolename,
tblAssets.IPAddress,
tblAssets.Lastseen,
tblAssets.Lasttried,
tblAssets.LastActiveScan,
tblFileVersions.Found,
tblFileVersions.FilePathfull,
tblFileVersions.FileVersion,
tblFileVersions.CompanyName,
tblFileVersions.Filesize
FROM
tblAssets
INNER JOIN tblAssetCustom ON tblAssets.AssetID = tblAssetCustom.AssetID
INNER JOIN tsysAssetTypes ON tsysAssetTypes.AssetType = tblAssets.Assettype
INNER JOIN tblFileVersions ON tblAssets.AssetID = tblFileVersions.AssetID
INNER JOIN tblComputersystem ON tblAssets.AssetID = tblComputersystem.AssetID
INNER JOIN tbldomainroles ON tbldomainroles.Domainrole = tblComputersystem.Domainrole
WHERE
tblAssetCustom.State = 1
WHERE
-- State = Active
tblAssetCustom.State = 1
-- DomainRole = workstation
AND tblComputersystem.Domainrole <= 1
-- Computer name doesn't start with 'HP-TC'
AND tblAssets.AssetName NOT LIKE 'HP-TC%'
-- first path has been searched for
AND Exists ( SELECT Top 1 tblFileVersions.Found
FROM tblFileVersions
WHERE tblFileVersions.AssetID = tblAssets.AssetID
AND tblFileVersions.FilePathfull = 'c:\windows\ccm\ccmexec.exe'
)
-- first path has been not-found
AND ( SELECT Count(*)
FROM tblFileVersions
WHERE tblFileVersions.AssetID = tblAssets.AssetID
AND tblFileVersions.FilePathfull = 'c:\windows\ccm\ccmexec.exe'
AND tblFileVersions.Found = 0
) > 0
-- second path has been searched for
AND Exists ( SELECT Top 1 tblFileVersions.Found
FROM tblFileVersions
WHERE tblFileVersions.AssetID = tblAssets.AssetID
AND tblFileVersions.FilePathfull = 'c:\windows\system32\ccm\ccmexec.exe'
)
-- second path has been not-found
AND ( SELECT Count(*)
FROM tblFileVersions
WHERE tblFileVersions.AssetID = tblAssets.AssetID
AND tblFileVersions.FilePathfull = 'c:\windows\system32\ccm\ccmexec.exe'
AND tblFileVersions.Found = 0
) > 0
WHERE
tblAssetCustom.State = 1
AND tblComputersystem.Domainrole <= 1
AND tblAssets.AssetName NOT LIKE 'HP-TC%'
-- custom file is one of those we're testing for
AND tblFileVersions.FilePathfull LIKE '%\ccm\ccmexec.exe'
...
‎11-05-2013 07:13 PM
SELECT Top 1000000
tblAssets.AssetID,
tblAssets.AssetName,
tsysAssetTypes.AssetTypename,
tsysAssetTypes.AssetTypeIcon10 As icon,
tblAssets.Domain,
tbldomainroles.Domainrolename,
tblAssets.IPAddress,
tblAssets.Lastseen,
tblAssets.Lasttried,
tblAssets.LastActiveScan,
tblFileVersions.Found,
tblFileVersions.FilePathfull,
tblFileVersions.FileVersion,
tblFileVersions.CompanyName,
tblFileVersions.Filesize
FROM
tblAssets
INNER JOIN tblAssetCustom ON tblAssets.AssetID = tblAssetCustom.AssetID
INNER JOIN tsysAssetTypes ON tsysAssetTypes.AssetType = tblAssets.Assettype
INNER JOIN tblFileVersions ON tblAssets.AssetID = tblFileVersions.AssetID
INNER JOIN tblComputersystem ON tblAssets.AssetID = tblComputersystem.AssetID
INNER JOIN tbldomainroles ON tbldomainroles.Domainrole = tblComputersystem.Domainrole
WHERE
tblAssetCustom.State = 1
WHERE
-- State = Active
tblAssetCustom.State = 1
-- DomainRole = workstation
AND tblComputersystem.Domainrole <= 1
-- Computer name doesn't start with 'HP-TC'
AND tblAssets.AssetName NOT LIKE 'HP-TC%'
-- first path has been searched for
AND Exists ( SELECT Top 1 tblFileVersions.Found
FROM tblFileVersions
WHERE tblFileVersions.AssetID = tblAssets.AssetID
AND tblFileVersions.FilePathfull = 'c:\windows\ccm\ccmexec.exe'
)
-- first path has been not-found
AND ( SELECT Count(*)
FROM tblFileVersions
WHERE tblFileVersions.AssetID = tblAssets.AssetID
AND tblFileVersions.FilePathfull = 'c:\windows\ccm\ccmexec.exe'
AND tblFileVersions.Found = 0
) > 0
-- second path has been searched for
AND Exists ( SELECT Top 1 tblFileVersions.Found
FROM tblFileVersions
WHERE tblFileVersions.AssetID = tblAssets.AssetID
AND tblFileVersions.FilePathfull = 'c:\windows\system32\ccm\ccmexec.exe'
)
-- second path has been not-found
AND ( SELECT Count(*)
FROM tblFileVersions
WHERE tblFileVersions.AssetID = tblAssets.AssetID
AND tblFileVersions.FilePathfull = 'c:\windows\system32\ccm\ccmexec.exe'
AND tblFileVersions.Found = 0
) > 0
WHERE
tblAssetCustom.State = 1
AND tblComputersystem.Domainrole <= 1
AND tblAssets.AssetName NOT LIKE 'HP-TC%'
-- custom file is one of those we're testing for
AND tblFileVersions.FilePathfull LIKE '%\ccm\ccmexec.exe'
...
Experience Lansweeper with your own data. Sign up now for a 14-day free trial.
Try Now