Jump to content


  • 0
pvr02

Devices Per OU With Friendly Name

Question

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

Share this post


Link to post
Share on other sites

5 answers to this question

Recommended Posts

  • 0

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.

Share this post


Link to post
Share on other sites

  • 0

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

Share this post


Link to post
Share on other sites

Join the conversation

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

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...


×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.