10-07-2024 10:42 PM
I need to create a computer report that contains a column with the OU and another where it indicates Win11, Anterior or X depending on the OU and sub OU:
OU=Coworking, OU=Workstations Win11, DC=dominio, DC=local
OU=Coworking, OU=Workstations, DC=dominio, DC=local
OU=Coworking, OU=Otra, DC=dominio, DC=local
OU=Workstations Win11, DC=dominio, DC=local = Win11
OU=Workstations, DC=dominio, DC=local = Anterior
OU=Otra, DC=dominio, DC=local = X
Select Top (1000000) Case
When Coalesce(tblADComputers.IsEnabled, 0) = 0 Then 'False'
Else 'True'
End As Enabled,
tblAssets.AssetID,
tblAssets.AssetName,
tblAssets.IPAddress As IP,
tblAssets.Username As [Usuario firmado],
tsysOS.OSname As OS,
tblAssets.OScode,
tblAssets.Version,
Case
When
tblADComputers.OU In
('%OU=Workstations Win11, DC=domain, DC=local%') Then 'Win 11'
When tblADComputers.OU In ('%OU=Workstations, DC=domain, DC=local%')
Then 'Anterior'
Else 'X'
End As Hardening,
tblADComputers.OU,
tsysIPLocations.IPLocation,
Coalesce(tsysOS.Image, tsysAssetTypes.AssetTypeIcon10) As icon,
tblAssets.Domain,
tblAssets.Lastseen As [Last successful scan],
tblAssets.Firstseen As [Created at],
tblAssets.Lasttried,
tblAssetCustom.PurchaseDate
From tblAssets
Left Outer Join tblSccmAsset On tblAssets.AssetID = tblSccmAsset.AssetId
Inner Join tblAssetCustom On tblAssets.AssetID = tblAssetCustom.AssetID
Inner Join tsysAssetTypes On tsysAssetTypes.AssetType = tblAssets.Assettype
Inner Join tblState On tblState.State = tblAssetCustom.State
Inner Join tsysIPLocations On tsysIPLocations.LocationID =
tblAssets.LocationID
Left Outer Join tblADComputers On tblAssets.AssetID = tblADComputers.AssetID
Left Outer Join tsysOS On tblAssets.OScode = tsysOS.OScode
Left Outer Join tblLinuxSystem On tblLinuxSystem.AssetID = tblAssets.AssetID
Left Outer Join tblMacOSInfo On tblMacOSInfo.AssetID = tblAssets.AssetID
Inner Join tblComputersystem On tblAssets.AssetID = tblComputersystem.AssetID
Where tblComputersystem.Domainrole < 2
Order By IP
In this report everything comes out with X
Solved! Go to Solution.
10-08-2024 04:33 PM
Hi,
I think the commas in the OU path are causing issues try a like statement something like
Case
When
tblADComputers.OU Like
'OU=Workstation%OU=Windows11%DC=Domain%DC=local' Then 'Win 11'
When tblADComputers.OU Like 'OU=workstations%DC=domain%DC=local' Then
'Anterior'
Else 'X'
End As Hardening,
10-09-2024 12:40 AM
It works:
Case
When
tblADComputers.OU Like
'%OU=Workstations Win11%DC=domainf%DC=local%' Then 'Win 11'
When tblADComputers.OU Like '%OU=Workstations%DC=domain%DC=local%'
Then 'Anterior'
Else 'X'
End As Hardening,
10-08-2024 04:33 PM
Hi,
I think the commas in the OU path are causing issues try a like statement something like
Case
When
tblADComputers.OU Like
'OU=Workstation%OU=Windows11%DC=Domain%DC=local' Then 'Win 11'
When tblADComputers.OU Like 'OU=workstations%DC=domain%DC=local' Then
'Anterior'
Else 'X'
End As Hardening,
10-09-2024 12:40 AM
It works:
Case
When
tblADComputers.OU Like
'%OU=Workstations Win11%DC=domainf%DC=local%' Then 'Win 11'
When tblADComputers.OU Like '%OU=Workstations%DC=domain%DC=local%'
Then 'Anterior'
Else 'X'
End As Hardening,
10-08-2024 06:07 PM
Continue the result of X in all fields
10-08-2024 07:27 PM
Have you got your new code for me to see ?
Experience Lansweeper with your own data. Sign up now for a 14-day free trial.
Try Now