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: 4
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: 512  
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 Driver vendor
by  miharix   Go to last post Go to first unread
Last post: Today at 3:04:54 PM(UTC)
Lansweeper SSH Scanning Credentials
by  BastiOn  
Go to last post Go to first unread
Last post: Today at 9:22:46 AM(UTC)
Lansweeper lansweeperuser sql database permissions
by  FrankSc   Go to last post Go to first unread
Last post: Today at 8:54:22 AM(UTC)
Lansweeper Software not showing install date
by  Rocher Vincent  
Go to last post Go to first unread
Last post: Today at 8:18:30 AM(UTC)
Lansweeper LSAgent Rescan Asset
by  marck1024   Go to last post Go to first unread
Last post: Yesterday at 6:46:48 PM(UTC)
Lansweeper Windows 10 20H2 issue
by  Mikey!  
Go to last post Go to first unread
Last post: Yesterday at 2:49:26 PM(UTC)
Lansweeper Use case for MSSP
by  CHTSjohn   Go to last post Go to first unread
Last post: 3/1/2021 10:49:11 PM(UTC)