Friday, 14 December 2012

Get disk space with Powershell

$computername='MyComputerName'

Get-WmiObject win32_logicaldisk -ComputerName $computername -Filter {freespace>0} | Format-Table @{l='Computername';e={$computername}},@{l='Drive';e={$_.DeviceID}},@{l='Size';e={(($_.Size/1024)/1024)/1024}}, @{l='FreeSpace';e={(($_.FreeSpace/1024)/1024)/1024}}

No comments:

Post a Comment