Notification

Icon
Error

Print Last OU instead of Full OU

Posted: Monday, January 11, 2021 9:26:50 PM(UTC)
Michael White

Michael White

Member Original PosterPosts: 3
0
Like
When I add tblADComputers.OU into a report, it prints the entire OU. Is there a way to have it only print the lowest level OU?

Ex:

Instead of printing `OU=WebServers,OU=Servers,OU=Computers,DC=EXAMPLE,DC=COM`

Just print `OU=WebServers`

Or even just `WebServers`
RC62N
#1RC62N Member Posts: 494  
posted: 1/11/2021 10:08:39 PM(UTC)
Take a look at the T-SQL string functions. You can use CharIndex() to check for the presence of a comma and, if present, return a truncated string using Left(), something like
Code:
CASE
  WHEN CharIndex(',', fullOU) > 0
  THEN Left(fullOU, CharIndex(',', fullOU)-1)
  ELSE fullOU
END AS lowOU

The simplest way to drop the "OU=" would probably be to wrap the CASE in a Replace().

Active Discussions

Lansweeper Rest API for Scanning
by  Brian Smith   Go to last post Go to first unread
Last post: Today at 7:35:27 PM(UTC)
Lansweeper Language translation not working anymore
by  Florian  
Go to last post Go to first unread
Last post: Today at 6:03:19 PM(UTC)
Lansweeper Use current user for scanning credentials?
by  pryan67   Go to last post Go to first unread
Last post: Today at 6:01:33 PM(UTC)
Lansweeper Bluetooth Info
by  FrankSc  
Go to last post Go to first unread
Last post: Today at 5:42:59 PM(UTC)
Lansweeper Question about Scanning Assets and Password Encryption
by  FrankSc   Go to last post Go to first unread
Last post: Today at 5:23:05 PM(UTC)
Lansweeper How to enable HTTPS in ver 6.0.150.60
by  Duncan.Miles  
Go to last post Go to first unread
Last post: Today at 1:11:19 PM(UTC)
Lansweeper INFO DateTimeService time refresh
by  miharix   Go to last post Go to first unread
Last post: Yesterday at 3:22:29 PM(UTC)
Lansweeper MS Edge Chromium LanSweeper Extension development
by  Slim D  
Go to last post Go to first unread
Last post: 1/15/2021 11:39:29 AM(UTC)