‎06-14-2024 08:30 PM
I have a report that shows us low diskspace which works but I want to exclude certain machines based on their OU or lack of being in certain OU's. The issues is the Not In does not seem to work as I want.
Select Top (1000000) tblAssets.AssetID,
tblAssets.AssetName,
tblAssets.Domain,
tblAssets.Username,
tblAssets.Userdomain,
Coalesce(tsysOS.Image, tsysAssetTypes.AssetTypeIcon10) As icon,
tblAssets.IPAddress,
tsysIPLocations.IPLocation,
tblAssetCustom.Manufacturer,
tblAssetCustom.Model,
tsysOS.OSname As OS,
tblAssets.SP,
tblAssets.Lastseen As [Last successful scan],
tblAssets.Lasttried As [Last scan attempt],
tblDiskdrives.Caption As Drive,
Cast(tblDiskdrives.Freespace / 1024 / 1024 / 1024 As numeric) As FreeGB,
Cast(tblDiskdrives.Size / 1024 / 1024 / 1024 As numeric) As TotalSizeGB,
tblDiskdrives.Lastchanged,
tblADComputers.OU
From tblAssets
Inner Join tblDiskdrives On tblAssets.AssetID = tblDiskdrives.AssetID
Inner Join tblComputersystem On tblAssets.AssetID = tblComputersystem.AssetID
Inner Join tblAssetCustom On tblAssets.AssetID = tblAssetCustom.AssetID
Inner Join tblState On tblState.State = tblAssetCustom.State
Inner Join tsysAssetTypes On tsysAssetTypes.AssetType = tblAssets.Assettype
Inner Join tsysIPLocations On tsysIPLocations.LocationID =
tblAssets.LocationID
Inner Join tblDomainroles On tblDomainroles.Domainrole =
tblComputersystem.Domainrole
Left Outer Join tsysOS On tblAssets.OScode = tsysOS.OScode
Inner Join tblADComputers On tblAssets.AssetID = tblADComputers.AssetID
Where Cast(tblDiskdrives.Freespace / 1024 / 1024 / 1024 As numeric) < 30 And
Cast(tblDiskdrives.Size / 1024 / 1024 / 1024 As numeric) <> 0 And
Cast(tblDiskdrives.Size / 1024 / 1024 / 1024 As numeric) > 10 And
tblADComputers.OU Not In ('OU=Citrix', 'OU=Servers', 'DC=WEMED', 'DC=com') And
tblState.Statename = 'Active' And tblDomainroles.Domainrolename In
('Stand-alone server', 'Member server', 'Primary domain controller',
'Backup domain controller') And Case tblDiskdrives.DriveType
When 3 Then 'Local Disk'
End = 'Local Disk'
Order By tblAssets.Domain,
tblAssets.AssetName,
Drive
‎06-18-2024 04:10 AM
Show string with code
‎06-17-2024 05:42 AM - edited ‎06-17-2024 05:47 AM
Try removing the spaces:
Replace(tblADComputers.OU, ' ','') Not In ('OU=Citrix,OU=Servers,DC=WEMED,DC=com')
‎06-17-2024 07:53 PM
That worked but having issues adding a second OU to this string. And/Or are not working for me.
Experience Lansweeper with your own data. Sign up now for a 14-day free trial.
Try Now