Search code examples
powershellvolumesformattable

PowerShell: column FriendlyName from Get-Volume is lost after I specify it in Format-Table


This happens on Microsoft Windows [Version 10.0.19044.3086]

I need specific fields from Get-Volume. Tried using Format-Table:

PS C:\Users\saukrs> Get-Volume | Format-Table -Property DriveLetter, FriendlyName, FileSystemType, DriveType, OperationalStatus, SizeRemaining, Size

DriveLetter FriendlyName FileSystemType DriveType OperationalStatus SizeRemaining          Size
----------- ------------ -------------- --------- ----------------- -------------          ----
          E              Unknown        Fixed     OK                 244047036416  244047675392
          C              NTFS           Fixed     OK                    145694720  255405891584
          D              NTFS           Fixed     OK                   1708548096 1000186310656
                         NTFS           Fixed     OK                     86540288     529526784

... but values the FriendlyName column/field are gone.

I expected them to be like in the original content. Please see drive letters C and D:

PS C:\Users\saukrs> Get-Volume | Format-Table

DriveLetter FriendlyName FileSystemType DriveType HealthStatus OperationalStatus SizeRemaining      Size
----------- ------------ -------------- --------- ------------ ----------------- -------------      ----
E                        Unknown        Fixed     Healthy      OK                    227.29 GB 227.29 GB
C           pagrindinis  NTFS           Fixed     Healthy      OK                     141.2 MB 237.87 GB
D           New Volume   NTFS           Fixed     Healthy      OK                      1.59 GB  931.5 GB
                         NTFS           Fixed     Healthy      OK                     82.53 MB    505 MB

Why is that? And how can this be fixed, please?


Solution

  • The FriendlyName property is not part of the object itself, but part of the default table view for MSFT_Volume instances.

    It's just the value of the FileSystemLabel property renamed to FriendlyName, and you can manually recreate it with a calculated property:

    Get-Volume |Format-Table Property DriveLetter,@{Name='FriendlyName';Expression='FileSystemLabel'},FileSystemType<#,... and so on #>