power shell脚本获取驱动器空间(使用百分比和免费)

时间:2016-10-10 14:12:31

标签: shell powershell command-line powershell-v2.0 powershell-v3.0

我正在尝试使用百分比DISK SPACE(Windows)和免费。

从中获取空间的脚本,

synchronized {}

1 个答案:

答案 0 :(得分:0)

你可以试试这个:

Get-WmiObject -Class win32_Logicaldisk -ComputerName localhost |  
where {($_.DriveType -eq 3 -or $_.DriveType -eq 2) -and $_.FileSystem -ne $null } |  
Select -Property 
@{Name = 'Volume';Expression = {$_.DeviceID -replace ":",""}}, 
@{Name = 'Free';Expression = { "{0:N0}%" -f (($_.FreeSpace/$_.Size) * 100) } }
相关问题