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: 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 Uninstall All versions of a software
by  Michael White   Go to last post Go to first unread
Last post: Yesterday at 7:31:07 PM(UTC)
Lansweeper Lansweeper Server Services - Running as what User acount ??
by  miharix  
Go to last post Go to first unread
Last post: Yesterday at 5:28:23 PM(UTC)
Lansweeper Antivirus: No antivirus installed
by  MB@CC-IT   Go to last post Go to first unread
Last post: Yesterday at 3:20:56 PM(UTC)
Lansweeper Report GPO's
by  Stian  
Go to last post Go to first unread
Last post: Yesterday at 9:59:20 AM(UTC)
Lansweeper Customize asset fields
by  Giuliano   Go to last post Go to first unread
Last post: Yesterday at 9:11:49 AM(UTC)
Lansweeper Asset Radar to cover all subnets
by  FrankSc  
Go to last post Go to first unread
Last post: 1/21/2021 7:51:36 PM(UTC)
Lansweeper Bluetooth Info
by  Alexey   Go to last post Go to first unread
Last post: 1/21/2021 10:37:44 AM(UTC)
Lansweeper Use current user for scanning credentials?
by  miharix  
Go to last post Go to first unread
Last post: 1/21/2021 8:31:56 AM(UTC)