-
-
Save ekmixon/f8840aa0b89a180ce44e42455687b66d to your computer and use it in GitHub Desktop.
HashTables.ps1
This file contains hidden or 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