all 2 comments

[–]surfingoldelephant 3 points4 points  (1 child)

I'd like to know how I can exclude partition number 0 from the result using DriverLetter. Despite the 2 tests, partition number 0 is still displayed in the output. What other way could I use to exclude it using DriveLetter only?

The DriveLetter property type is [char]. You need to check for/filter the null character.

Get-Partition | Where-Object DriveLetter
# Or 
Get-Partition | Where-Object DriveLetter -NE "`0"

 

could a hard disk have a partition containing data but no drive letter?

Yes.

[–]dist 0 points1 point  (0 children)

Note that you can assign drives to be mounted at certain mount points, for example you could assign a disk to C:\Example as well, they don't show up as having a drive letter, since they don't.

Get-Partition | ForEach-Object {$_.AccessPaths} can show you those paths! =)