Disclaimer
This is my personal blog. The opinions and views I express are my own. The information I provide is on an as-is basis. I make no representations as to accuracy, completeness, currentness, suitability, or validity of any information on this blog and will not be liable for any errors, omissions, or delays in this information or any losses, injuries or damages arising from its use.

Remotely retrieve disk size, FreeSpace and % of FreeSpace with PowerShell

This script uses the win32_LogicalDisk WMI Class to get Local Disk Information for one or multiple computers. For more information on the DriveTypes available with the Win32_LogicalDisk class visit: https://technet.microsoft.com/en-us/library/ee176674.aspx.

You could also expand on this script and add email capability and schedule it as a job or a scheduled task. That way it runs without human input on a scheduled basis and emails the results.

Information retrieved:
System Name, DeviceID, Volume Name, Size(GB), FreeSpace(GB), % FreeSpace(GB), and the date/time the script is executed.

Output options included: Out-Gridview, a Table, CSV file and an HTML file.

 

 

3 Comments

  1. M Federlechner | | Reply

    Thanks, David! Nice work, but same Problem as these two guys above. What should like to look the computers.txt

  2. Martin Bluck | | Reply

    This looks good, could you please provide an example of what the computers.txt file should look like?

  3. runebjorndal | | Reply

    This script looks really usefull! Can you please provide an example on how the computers.txt file is supposed to look like? I tried it on my local client first with only my hostname inside but get the error:

    Get-Content : Cannot find path ‘C:\scripts\drive_info\computers.txt’ because it does not exist.
    At line:1 char:1
    + Get-Content “C:\scripts\drive_info\computers.txt”
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : ObjectNotFound: (C:\scripts\drive_info\computers.txt:String) [Get-Content], ItemNotFoundException
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetContentCommand

    I’ve checked the file paths 🙂

    Thanx.
    Rune

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.