power shell 获取驱动器 space 的脚本(已用百分比和免费百分比)

power shell script to get drive space ( percentage used and free )

我正在尝试获取 DISK SPACE (Windows) 的已用百分比和免费。

我从中获取 space、

的脚本
 get-psdrive | where Free*

你可以试试这个:

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) } }