locked
Percentage for Disk Space Utilization RRS feed

  • Question

  • Hi,

    We get Disk Space Utilization by below command

    Get-WmiObject –class “Win32_logicaldisk” –ComputerName <Server name> –Filter “DeviceID=’C:’”

    Result:

    DeviceID     : C:
    DriveType    : 3
    ProviderName :
    FreeSpace    : 3648880640
    Size         : 53684989952
    VolumeName   : System

    Please help to get the result for free Space in Percentage like.. 8%, 10%, using single line command.


    Bishmeet Singh

    Monday, May 8, 2017 6:19 PM

Answers

  • If you really like % signs then do this:

    Get-WmiObject Win32_logicaldisk  –Filter 'DeviceID="C:"'|
         select @{n='FreeSpace %';e={'{0:P1}' -f ($_.FreeSpace/$_.Size)}}


    \_(ツ)_/



    Monday, May 8, 2017 6:44 PM

All replies

  • Freespace/Size * 100

    Simple elementary school arithmetic.  "FreeSpace" and "Size" are properties of the volume.


    \_(ツ)_/

    Monday, May 8, 2017 6:40 PM
  • Yes, Indeed. But how to Embed it to Get-WmiObject –class “Win32_logicaldisk” –ComputerName <Server name> –Filter “DeviceID=’C:’” ??

    I need One Shot to get the Percentage Directly


    Bishmeet Singh

    Monday, May 8, 2017 6:43 PM
  • If you really like % signs then do this:

    Get-WmiObject Win32_logicaldisk  –Filter 'DeviceID="C:"'|
         select @{n='FreeSpace %';e={'{0:P1}' -f ($_.FreeSpace/$_.Size)}}


    \_(ツ)_/



    Monday, May 8, 2017 6:44 PM
  • Thanks \_(ツ)_/ jrv , This is what I was looking for.

    Bishmeet Singh

    Monday, May 8, 2017 7:01 PM
  • Monday, May 8, 2017 7:08 PM
  • Just for comment, if you find the answer helpful or solve your problem. Please do not forget to mark as answered by clicking "Propose as answer"
    Sunday, May 28, 2017 7:16 PM