Back to all posts

What Modules Do I Have and How Many Of Them?

Posted on Mar 25, 2008

Posted in category:
Development
DNN

Finding out how many modules you have installed on a site, and additionally how many times those modules are used is something that you would think is very simple within DotNetNuke. However, it is a bit more complex than one would hope. By default DNN does not provide a mechanism for you to perform this kind of research, however, I have a very simple SQL Script that will allow you to see ALL modules and from there the total number of instances (in all portals) and the total number of instances that are deleted (in the recycle bin). From an administrative perspective, this is a key piece of information to know.

Module List Query
SELECT
    DM.ModuleName,
    DM.FriendlyName,
    (SELECT COUNT(*) 
     FROM Modules 
       WHERE ModuleDefId = MD.ModuleDefId
    ) AS 'TotalInstances',
    (SELECT COUNT(*) 
      FROM Modules 
     WHERE ModuleDefId = MD.ModuleDefId 
        AND IsDeleted = 1
    ) AS 'RecycleBinInstances' 
FROM DesktopModules DM
    INNER JOIN ModuleDefinitions MD 
        ON DM.DesktopModuleID = MD.DesktopModuleID 
GROUP BY DM.ModuleName, DM.Friendlyname, MD.ModuleDefId 
ORDER BY 'TotalInstances'

Just run this script and you will quickly see all modules and module counts. A few things to note, if you have multiple portals this script will give only 1 count. Additionally, this script will show you ALL modules, including "host" and "admin" modules provided by the DNN core. However, as a general rule, this should help you with your next administration task.