下面是检查磁盘空间的代码:
$disks = Get-WmiObject -ComputerName WDSMS01 -Namespace root\cimv2 -Query "Select * from Win32_LogicalDisk where DriveType=3"
$disks.DeviceID
$dsql01 = @()
foreach($db in $disks)
{
$dsql = New-Object PSObject
$dsql | Add-Member -MemberType NoteProperty -Name "Drive Name" -value $db.DeviceID
$dsql | Add-Member -MemberType NoteProperty -Name "Total Space(GB)" -value ($db.Size/1GB)
$dsql | Add-Member -MemberType NoteProperty -Name "Free Space(GB)" -value ($db.FreeSpace/1GB)
$dsql01 += $dsql
}
$dsql01
是否可以将小数限制为 2 位?此外,添加另一个以 % 格式计算可用空间的列。
谢谢。