因此,我正在为我们的服务器编写库存脚本,但在存储方面遇到了障碍。这是代码:
$StorageInfo=Get-WmiObject win32_volume | Where-Object {$_.DriveType -eq 3 -and $_.Label -ne 'System Reserved' -and $_.DriveLetter -ne $null}
$DriveLetters=$StorageInfo | Select-Object DriveLetter | Sort-Object DriveLetter | ft -HideTableHeaders
$DriveNames=$StorageInfo | Sort-Object DriveLetter | Select-Object Label | ft -HideTableHeaders
$DriveCapacity=$StorageInfo |Sort-Object DriveLetter | ForEach-Object {[Math]::Truncate($_.Capacity / 1GB)}
$DriveLetters
$DriveNames
$DriveCapacity
从中得到的数据如下:
C:
D:
E:
F:
G:
OSDisk
Data
SQL Data
SQL Logs
SQL Temp
232
97
97
97
48
我希望能够像这样格式化它:
C:\, OSDisk - 232gb
D:\, Data - 97gb
C:\, SQLData - 97gb
C:\, SQLLogs - 97gb
C:\, SQLTemp - 97gb
......我无法完全弄清楚这一点。任何人都可以提供帮助吗?