Important Notice: On February 29th, this community was put into read-only mode. All existing posts will remain but customers are unable to add new posts or comment on existing. Please feel to join our Community Discord for any questions and discussions.

Get Desktop Folder size from Inventory?

I would like to know it there is a simple\easy way to get the size of a Users Desktop using PDQ Inventory? I have a need to pull a report showing the size of our Users' desktops in order to lambaste a few that ignore our directives to put mission-critical files in their Documents folder, which we backup nightly. If I am going to be able to justify the expense of additional storage in order to backup Users desktops, I need to know how much is out there. Help\advice is greatly appreciated.

Ralph Miller

1

Comments

3 comments
Date Votes
  • Ralph,

    It's not particularly simple/easy, but it should be possible with the combination of a Files & Directories scanner and a SQL report. Here is what I put in my Files & Directories scanner in my test scan profile:

    Type:
    File

    Include Pattern(s):
    C:\Users\*\Desktop\**\

    This populates the PDQ database with a list of files on users' desktops and those file sizes. I was then able to get a rudimentary SQL report that is almost what you want with this syntax:

    select
         Computers.Name as "Computer Name",
         FilePaths.PathName,
         Files.FileName,
         Files.Size as "Size (Bytes)"
    from Computers,Files,FilePaths
    where <ComputerFilter>
    AND Files.ComputerId == Computers.ComputerId
    AND FilePaths.FilePathId == Files.FilePathId
    AND FilePaths.PathName LIKE "%Desktop%"
    AND Files.FileName NOT LIKE "desktop.ini"
    AND Files.FileName NOT LIKE "%.lnk"
    AND Files.FileName NOT LIKE "%.url"

    You could probably add some additional SQL in the report to automatically tally up the sizes of the files and change it to display the file sizes in something more readable like KB instead of bytes, but this is what I came up with in my brief test. The data that you want is there, it's just a matter of how best to display it.

    Note that I added several exceptions for desktop shortcuts, web shortcuts, and the desktop.ini file that you would expect to see on everyone's desktop.

    Maybe someone who's more adept at SQL can chime in to help get you the rest of the way there.

    2
  • After more testing I was able to refine the SQL report to display file sizes in KB, MB, and GB. I also set it to tally up the file sizes per computer. It might be possible to tally it per user, but it would involve breaking up the FilePaths.PathName value by its \ delimiter and grouping by the username which would be the 3rd token. I'm not proficient enough in SQL to do that. I removed the file names and file paths from the report since it was broken due to the "Group By" statement.

    Here is my latest version:

    select
         Computers.Name as "Computer Name",
         Computers.ADDescription,
         (SUM(Files.Size) / 1024) as "Total Desktops (KB)",
         (SUM(Files.Size) / 1048576) as "Total Desktops (MB)",
         (SUM(Files.Size) / 1073741824) as "Total Desktops (GB)"
    from Computers,Files,FilePaths
    where <ComputerFilter>
         AND Files.ComputerId == Computers.ComputerId
         AND FilePaths.FilePathId == Files.FilePathId
         AND FilePaths.PathName LIKE "%Desktop%"
         AND Files.FileName NOT LIKE "desktop.ini"
         AND Files.FileName NOT LIKE "%.lnk"
         AND Files.FileName NOT LIKE "%.url"
    GROUP BY Computers.Name

    1
  • I was also looking for a way to use PDQ to find a folder size, in my case the Windows\Installer directory. Here's how I did it. You can apply this to any single folder.

    If you only have PDQ Inventory:

    Go to Tools > Run Command, and run this Powershell on your target computer(s) using the appropriate credentials:

    $totalsize=[long]0;gci -path c:\windows\installer\ -File -r -fo -ea Silent|%{$totalsize+=$_.Length};$totalsize;New-Item C:\Windows\Temp\My_Folder\$totalsize.txt -Force

    This will create an empty file in the 'My_Folder' folder with a filename of the total size of your folder, in bytes; in my case c:\windows\installer.

    From there, create a Scan Profile to scan 'My_Folder' and run a report. I exported the report to CSV so that I could separate and categorize the data.

    If you have both Inventory and Deploy, you can run the command using Deploy, and then get the results with Inventory. Either way, it's a pretty quick one-liner.

    1