So I'm working on an inventory script for our servers and have hit a roadblock at the storage. Here's the code:
$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
The data that comes from that is as follows:
C:
D:
E:
F:
G:
OSDisk
Data
SQL Data
SQL Logs
SQL Temp
232
97
97
97
48
I'd like to be able to format it as such:
C:\, OSDisk - 232gb
D:\, Data - 97gb
C:\, SQLData - 97gb
C:\, SQLLogs - 97gb
C:\, SQLTemp - 97gb
...and I can't quite figure this out. Can anyone offer assistance?