【问题标题】:power shell script to get drive space ( percentage used and free ) [duplicate]用于获取驱动器空间的 power shell 脚本(已用百分比和可用百分比)[重复]
【发布时间】:2017-02-18 23:54:10
【问题描述】:

我正在尝试获取磁盘空间 (Windows) 的已使用百分比和空闲百分比。

我从中获得空间的脚本,

 get-psdrive | where Free*

【问题讨论】:

  • 这听起来更像是一个三年级的数学问题,而不是一个编程问题。你的问题到底是什么?

标签: shell powershell command-line powershell-2.0 powershell-3.0


【解决方案1】:

你可以试试这个:

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

【讨论】:

    猜你喜欢
    • 2022-01-27
    • 1970-01-01
    • 2011-02-02
    • 1970-01-01
    • 1970-01-01
    • 2014-04-23
    • 1970-01-01
    • 1970-01-01
    • 2015-04-24
    相关资源
    最近更新 更多