Get-PSDrive in PS 5.1 ISE works differently on Win7 vs. Win10

I have the following statement

$Volname='PATRIOT'

Get-PSDrive | Where-object Description -eq $Volname  |

Write-host

I mount an external USB flash drive to satisfy the $Volname and it correctly returns the drive letter (H, I, whatever). This is on a Windows 7 (64-bit) PC.

I take this exact same line of code to a Windows 10 PC and it fails here because the Get-PSDrive worked differently: the Description field here returned blanks. The objective is to extract the mapped drive letter based on the volume name (label) of the mounted disc. It is assumed the volume name (label) is unique insofar as the PC it is mounted to is concerned, i.e., no duplicates.

As far as getting something “that works on both Win7 and Win10” goes, I’ve reverted to using Get-CIMinstance. I am just wondering why Get-PSDrive works differently on Win7 / Win10. Both Windows PCs were running Powershell 5.1 ISE.

Would be grateful if someone can shed some light on this behavior.

Thanks in advance.

If i try this on my windows 10 machine I get the following result,

$Volname='C-test'
Get-PSDrive | Where-object Description -eq $Volname |Select-Object *
Used : 420962443264 Free : 89808359424 CurrentLocation : Users\bdv Name : C Provider : Microsoft.PowerShell.Core\FileSystem Root : C:\ Description : C-test MaximumSize : Credential : System.Management.Automation.PSCredential DisplayRoot :
PS C:\Users\bdv>
 

The first time it didn’t work because my machine didn’t have an description filed in for the C drive,

even after changing that I needed to restart powershell for it to work

Thanks Bart. Is your test example a USB flash drive?

No this was my C drive,

 

I tested this with an USB disk and the description is empty,

Looks like a Bug with USB disks

Thanks, much appreciated.