DriveLetter is a property of each object inside your $DriveLetters array. $DriveLetters is NOT an array of strings. If you pipe $DriveLetters to Get-Member, you’ll see it. Change your if statement to reference that property of the object using the dot operator or use the -ExpandProperty to return the <string> value of that property (then $DriveLetters will be an array of string objects). Here’s a simple illustration to show the problem.