→ 🚀What's New? Explore Lansweeper's Fall 2024 Updates! Fall Launch Blog !

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
WemedWizard
Engaged Sweeper II

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

3 REPLIES 3
Mister_Nobody
Honored Sweeper II

Show string with code

Mister_Nobody
Honored Sweeper II

Try removing the spaces:
Replace(tblADComputers.OU, ' ','') Not In ('OU=Citrix,OU=Servers,DC=WEMED,DC=com')

That worked but having issues adding a second OU to this string. And/Or are not working for me.