Skip to content

Instantly share code, notes, and snippets.

@signalwarrant
Created March 9, 2021 18:46
Show Gist options
  • Save signalwarrant/13190ae52fa7ee1af20b2ce268d42a66 to your computer and use it in GitHub Desktop.
Save signalwarrant/13190ae52fa7ee1af20b2ce268d42a66 to your computer and use it in GitHub Desktop.
HashTables.ps1
# Example No Hash table or Calculated Properties
Get-WmiObject -Class WIN32_volume -ComputerName localhost -Filter 'drivetype = 3' |
Select-Object -Property PScomputerName,
DriveLetter,
Label,
FreeSpace
# Example using a Hash table
Get-WmiObject -Class WIN32_volume -ComputerName localhost -Filter 'drivetype = 3' |
Select-Object -Property PScomputerName,
DriveLetter,
Label,
@{
LABEL='FreeSpace(GB)';
EXPRESSION={($_.freespace/1GB)}
}
# Better but not exactly what we're looking for.
Get-WmiObject -Class WIN32_volume -ComputerName localhost -Filter 'drivetype = 3' |
Select-Object -Property PScomputerName,
DriveLetter,
Label,
@{
LABEL='FreeSpace(GB)';
EXPRESSION={'{0:N2}' -f ($_.freespace/1GB)}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment