Scan Freespace of Physical Disk



  • Colby Bouma

    I think your best bet would be to use "PDQInventory.exe ImportCustomFields". You will need to save the data to a CSV file and import it into a Custom Field with that command. 

    Comment actions Permalink
  • Bohren Andreas

    Thank you for your idea.

    If I have understood correctly, we have to scan our computers by running the mentioned Powershell command (outside of PDQ Inventory) and after this, we have to import the results to PDQ Inventory?

    Hmm, I had rather hoped, that we can use the "custom Tools" in PDQ Inventory ( . But I don't know how to save eg. PercentFree in a Custom Field of PDQ Inventory.

    Best regards,




    Comment actions Permalink
  • Stephen Valdinger

    This likely *could* be done with a custom tool, but you'll still be leveraging pdqinventory.exe and not a scanner to complete the task. 


    What you'd want to do is create a new object for each machine you are running the code against which 2 NoteProperties: ComputerName and FreeSpace. 

    Next you would pipe the values of that object to a CSV file


    Foreach($computer in $remotecommandtargets){

    $FreeSapce = <your code here>

    $obj = New-Object PSObject

    $obj | Add-member -Type NoteProperty -Name ComputerName -Value $computer

    $obj | Add-member -Type NoteProperty -Name FreeSpace -Value $FreeSpace

    $obj | Out-File -Path \path\to\csv -Append -Force




    Then you would create another block of code that leverages pdqinventory.exe to bring that custom field data back into Inventory.


    Custom Fields are setup in Preferences in Inventory here:

    This documentation should get you started with understanding how custom fields work:

    And here is some further documentation on Importing through the PDQ interface:


    I'm not up to speed on the pdqinventory sql tables, so maybe Colby or Shane could be of better help as far as building out the query and or use of the ImportCustomFields command line tool. I'd hate to take an untested guess at it and be wrong.

    Comment actions Permalink
  • Colby Bouma


    I'm a little confused about what you're looking for. The PowerShell example you provided seems to grab the same information PDQ does. Are you looking for unpartitioned space on the disks? Once I understand exactly what you're looking for I will put together a Tool for Inventory.

    Comment actions Permalink
  • Colby Bouma

    This is what I have so far based on what I think you're asking for. It's a SQL report. The biggest flaw is that Inventory doesn't scan special partitions like System Reserved, so this will always report Free Space > 0 for the system drive of computers >= Vista. I will put in a feature request for that.

    Physical Disk Free Space.xml

    <?xml version="1.0" encoding="utf-8"?>
    <AdminArsenal.Export Code="PDQInventory" Name="PDQ Inventory" Version="" MinimumVersion="3.1">
    <ReportDefinition name="Definition">

    Computers.Name AS "Computer Name",
    DiskDrives.DiskDeviceId AS "Disk Device Id",
    -- This subtracts the total size of all scanned partitions from each disk
    ( ( DiskDrives.Size - LogicalDisksTotal.Size ) / 1024 / 1024 ) AS "Disk Free Space MB"
    -- This aggregates the size of all paritions for each disk
    SUM(Size) AS "Size"
    ) LogicalDisksTotal
    Computers ON Computers.ComputerId = DiskDrives.ComputerId
    -- This 2 part INNER JOIN is required for computers that have multiple disks
    DiskDrives ON DiskDrives.ComputerId = LogicalDisksTotal.ComputerId
    DiskDrives.DiskDeviceId = LogicalDisksTotal.DiskDeviceId
    WHERE &lt;ComputerFilter&gt;
    "Computer Name",
    "Disk Device Id"</Sql>
    <Description>Report for</Description>
    <Name>Physical Disk Free Space</Name>
    <ReportFolderId value="1" />

    It's a little easier to read with some syntax highlighting:

    Comment actions Permalink
  • Bohren Andreas

    Hi there

    Thank you, Stephen and Colby, for your informations and your efforts! That's really kind of you!

    @Colby: Sorry for confusing. My english is really bad - I know :-(  - but I try to explain our problem again :-)

    We have several computers with SSD Harddisks (size of 112 GB) inside. With an Imaging tool, we have created a Master image and deployed this on these computers.
    This basic image comes standard with an approx. size of 36 GB. Because of the Snapshot technology, each change on the imaged Computer (ex. creating of user profiles, installation of applications etc.) will increase (or grow up) the basic image.
    The size of the Logical Drive does not change, but the snapshot components creates additional files and saves these also on the harddisk.
    In fact, not only the image file is stored on the harddisk, but also the snapshot files. Therefore, the free space on the hard disk shrinks and shrinks.

    The next deployment of master images, we will do without this snapshot technology. Until this deployment, the existing imaged computers have to been monitored. When the hard disk is full, a start of the computer is no more possible. So I have to act proactively.

    In your SQL query, Colby, you create (if I have understood correctly) a difference between the size of the physical and the logical drive. Because the logical drive size of 110 GB does not change, this report shows me for the most of the concerned systems a value (free size) of 125 MB.

    I will also try the solution from Stephen and let you know, if I have found a solution.

    Thank you again!

    Best regards,

    Comment actions Permalink
  • Colby Bouma

    Your English isn't bad at all! You just have an unusual situation and I wasn't sure what you were trying to ask for :)

    What is the name of this imaging software? If we understand how it works we will be more capable of helping you. When you said Virtual Disks in your original post I thought you were talking about virtual machines :) This sounds way more interesting.

    Comment actions Permalink

Please sign in to leave a comment.