Get Desktop Folder size from Inventory?

Comments

3 comments

  • Luke Nichols

    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
    Comment actions Permalink
  • Luke Nichols

    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
    Comment actions Permalink
  • Leigh Warner

    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
    Comment actions Permalink

Please sign in to leave a comment.