【发布时间】:2017-02-18 23:54:10
【问题描述】:
我正在尝试获取磁盘空间 (Windows) 的已使用百分比和空闲百分比。
我从中获得空间的脚本,
get-psdrive | where Free*
【问题讨论】:
-
这听起来更像是一个三年级的数学问题,而不是一个编程问题。你的问题到底是什么?
标签: shell powershell command-line powershell-2.0 powershell-3.0
我正在尝试获取磁盘空间 (Windows) 的已使用百分比和空闲百分比。
我从中获得空间的脚本,
get-psdrive | where Free*
【问题讨论】:
标签: shell powershell command-line powershell-2.0 powershell-3.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) } }
【讨论】: