Created
March 9, 2021 18:46
-
-
Save signalwarrant/13190ae52fa7ee1af20b2ce268d42a66 to your computer and use it in GitHub Desktop.
HashTables.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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