Power Shell脚本以获取驱动器空间(已用百分比和可用百分比) [英] power shell script to get drive space ( percentage used and free )

查看:74
本文介绍了Power Shell脚本以获取驱动器空间(已用百分比和可用百分比)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试免费使用百分比形式的DISK SPACE(Windows).

I am trying to get DISK SPACE (Windows) in Percentage used and free.

我从中获得空格的脚本

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

这篇关于Power Shell脚本以获取驱动器空间(已用百分比和可用百分比)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆