Skip to content

Instantly share code, notes, and snippets.

@vexx32

vexx32/sdolcourt96.ps1 Secret

Last active Nov 16, 2018
Embed
What would you like to do?
# With Select-Object
Get-CimInstance -Class Cim_LogicalDisk $Session |
Where-Object DriveType -eq 3 |
Select-Object -Property Name, VolumeName, @{
Name = 'Size'
Expression = { "{0:N2}" -f ($_.Size / 1gb) }
}, @{
Name = 'FreeSpace'
Expression = { "{0:N2} -f ($_.FreeSpace / 1gb) }
}
# Building with Hashtable
Get-CimInstance -Class Cim_LogicalDisk $Session |
Where-Object DriveType -eq 3 |
ForEach-Object {
[PSCustomObject]@{
Name = $_.Name
VolumeName = $_.VolumeName
Size = "{0:N2}" -f ($_.Size / 1gb)
FreeSpace = "{0:N2}" -f ($_.FreeSpace / 1gb)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment