Skip to content

Instantly share code, notes, and snippets.

@ekmixon
Forked from signalwarrant/HashTables.ps1
Created October 4, 2021 18:06
Show Gist options
  • Select an option

  • Save ekmixon/f8840aa0b89a180ce44e42455687b66d to your computer and use it in GitHub Desktop.

Select an option

Save ekmixon/f8840aa0b89a180ce44e42455687b66d 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