Skip to content

Devices Per OU With Friendly Name

Featured Replies

I'm looking to get a report that will show me how many devices we have in each location. The best way to do this would be by using OU information.

 

I located the script on this page that will show me each OU but would like to modify it so that it so it shows a more descriptive name instead of the OU. Is this something easy to adjust?

select
    ou.ou,
    count(*) as 'total'
from
    (SELECT sys.ResourceID, max(OU.System_OU_Name0) AS 'OU' FROM dbo.v_R_System AS sys INNER JOIN dbo.v_RA_System_SystemOUName AS ou ON sys.ResourceID = ou.ResourceID GROUP BY sys.ResourceID) ou
group by 
    ou.ou
Order by 
    ou.ou
  • Author

Instead of showing 'domain\usa\california\sacramento\desktops' to be able to show 'Sacramento Desktops'.

So how exactly would you determine that that OU is called Sacramento Desktops?

 

It sound like a manual process to me. As such you can use a monster "Case" statement to convert each OU into a better description.

  • Author

I checked into the case statements and was able to figure it out.

 

Thanks for your help.

select
    ou.ou,
    count(*) as 'total'
from
    (SELECT sys.ResourceID, case 
when max(OU.System_OU_Name0) like 'domain/usa/california/sacramento/desktop%' THEN 'Sacramento Desktops' 
when max(OU.System_OU_Name0) like 'domain/usa/california/sacramento/laptop%' THEN 'Sacramento Laptops' 
ELSE max(OU.System_OU_Name0) END 
AS 'OU' FROM dbo.v_R_System AS sys INNER JOIN dbo.v_RA_System_SystemOUName AS ou ON sys.ResourceID = ou.ResourceID GROUP BY sys.ResourceID) ou
group by 
    ou.ou
Order by 
    ou.ou

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.