Powershell查询查找总磁盘使用情况

标签 powershell wmi diskspace

我正在尝试查找 powershell(或 WMI)查询来查找 PC 中磁盘空间利用率的总和。我有以下查询... enter image description here

但正如您在图像中看到的,它为每个驱动器显示单独的行。 如何获取磁盘空间总量。

塞巴斯蒂安

最佳答案

Measure-Object 应该可以很好地为您完成这项工作。您没有具体说明您要查找的数据,因此这将给出 FreeSpaceSize 的总和。

Get-WmiObject -class win32_logicaldisk | Measure-Object -Sum freespace,size
-or-
Get-WmiObject -class win32_logicaldisk | Measure-Object -Sum size

您需要从中提取总和才能发挥作用。

关于Powershell查询查找总磁盘使用情况,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26674669/

相关文章:

database - Sonar 数据库有多大?

windows - 为什么 PowerShell 无法识别带引号的参数?

windows - 将函数的返回值赋给变量时不显示输出

.net - 在 Windows 7 下从 .NET 应用程序中查找 USB 串口

ruby-on-rails - unicorn 吃内存

linux 磁盘空间数字没有相加

powershell - 我是否需要try/catch和-ErrorAction?

powershell - 我们可以使用 Java 代码执行 Windows Azure PowerShell

windows - Powershell:获取所有挂起的任务

java - 在提升模式下执行 wmi 命令 Enable-PSRemoting