How is the default output of get-psdrive determined? It’s formatted as a table (not autosized), and Used and Free are given in gigabytes. The output object type is “PSDriveInfo”.
Name Used (GB) Free (GB) Provider Root CurrentLocation
---- --------- --------- -------- ---- ---------------
/ 152.92 293.19 FileSystem /
But if I pipe it to format-list * (I have to say ‘*’ to get all properties), Used and Free are given in bytes:
This is by design.
What you are seeing in the list view is the same as you would see if you displayed all the properties
Get-PSDrive | Select -Property * | Where Name -eq ‘C’
Results
Used : 254887346176
Free : 255709757440
CurrentLocation :
Name : C
Provider : Microsoft.PowerShell.Core\FileSystem
Root : C:
Description : Root
MaximumSize :
Credential : System.Management.Automation.PSCredential
DisplayRoot :
Get-PSDrive by itself is a summary of the drive info and uses calculated name properties. This is not uncommon for many cmdlets.
As for the PoSH default view of virtually any output 5 and below is always shown as a table. As shown by the all properties call above.
Output greater than 5 is always a list for the complete detail display.
When you see results like what your post indicates, be sure to do two things so that you grasp what it does and the expected delivery results.
1 - Always look at the help files
Get-Help -Name Get-PSDrive -Full
The default output is actually determined by the format.ps1xml where that object type exists. In this case that file is $pshome\PowerShellCore.format.ps1xml.
Another good example of this is with Get-Process. The default output for that is:
Handles NPM(K) PM(K) WS(K) CPU(s) Id SI ProcessName
------- ------ ----- ----- ------ -- -- -----------
If you run a Get-Member on Get-Process though you will not find a property named PM(K) or WS(K). It’s just PM or WS. The output is determined by the format.ps1xml that handles process objects. These files aren’t well documented so getting a book like ‘Powershell in Depth’ will definitely help.