Home > Informatica, PowerShell > [Power Shell] Disk Space Monitor

[Power Shell] Disk Space Monitor

Ecco a voi un piccolo script per il controllo dello spazio sugli hd, realizato con powershell

$drives = Get-WmiObject  Win32_LogicalDisk | Where-Object {$_.DriveType -eq 3}
clear
echo "Drive Letter    Drive Size    Free Space    Percent Free" 
echo "————    ———-    ———-    ————"
foreach($drive in $drives)
{
        $size1 = $drive.size / 1GB 
        $size = "{0:N2}" -f $size1
        $free1 = $drive.freespace / 1GB
        $free = "{0:N2}" -f $free1
        $ID = $drive.DeviceID
        $a = $free1 / $size1 * 100
        $b = "{0:N2}" -f $a
Write-Host "$ID              $size gb      $free gb       $b gb"       
}

l’output dello script sarà simile il seguente

Drive Letter    Drive Size    Free Space    Percent Free
————    ———-    ———-    ————
C:              110,05 gb      21,80 gb       19,81 gb
D:              110,07 gb      25,14 gb       22,84 gb

  1. Nessun commento ancora...
  1. Nessun trackback ancora...