Scan Freespace of Physical Disk

Comments

7 comments

  • 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. 

    0
    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 (http://documentation.adminarsenal.com/PDQInventory/10.1.0.0/index.html?using-custom-tools.htm) . But I don't know how to save eg. PercentFree in a Custom Field of PDQ Inventory.

    Best regards,

    Andreas

     

     

    0
    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

    (Think:

    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:

    https://www.adminarsenal.com/blog/adding-your-own-custom-data-to-pdq-inventory/

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

    http://documentation.adminarsenal.com/PDQInventory/12.2.0.0/

     

    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.

    0
    Comment actions Permalink
  • Colby Bouma

    @Bohren

    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.

    0
    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="12.2.0.0" MinimumVersion="3.1">
    <Report>
    <ReportDefinition name="Definition">
    <Sql>/*
    Sources:
    http://stackoverflow.com/a/4110597
    http://www.sqlitetutorial.net/sqlite-inner-join/
    http://www.sqlitetutorial.net/sqlite-group-by/
    https://sqlite.org/lang_comment.html
    */

    SELECT
    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"
    FROM
    -- This aggregates the size of all paritions for each disk
    (
    SELECT
    ComputerId,
    DiskDeviceId,
    SUM(Size) AS "Size"
    FROM
    LogicalDisks
    GROUP BY
    ComputerId,
    DiskDeviceId
    ) LogicalDisksTotal
    INNER JOIN
    Computers ON Computers.ComputerId = DiskDrives.ComputerId
    INNER JOIN
    -- This 2 part INNER JOIN is required for computers that have multiple disks
    DiskDrives ON DiskDrives.ComputerId = LogicalDisksTotal.ComputerId
    AND
    DiskDrives.DiskDeviceId = LogicalDisksTotal.DiskDeviceId
    WHERE &lt;ComputerFilter&gt;
    ORDER BY
    "Computer Name",
    "Disk Device Id"</Sql>
    <ReportDefinitionTypeName>SqlReportDefinition</ReportDefinitionTypeName>
    </ReportDefinition>
    <Description>Report for https://support.adminarsenal.com/hc/en-us/community/posts/115000012311</Description>
    <Name>Physical Disk Free Space</Name>
    <ReportFolderId value="1" />
    <ReportType>SqlReport</ReportType>
    </Report>
    </AdminArsenal.Export>

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

    0
    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,
    Andreas

    0
    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.

    0
    Comment actions Permalink

Please sign in to leave a comment.