Hi Guys,
I write a fair amount of PS but this has got me. I bet I’m missing something very basic.
$DriveLetters=Get-Volume |
Where-Object {($.DriveLetter -ne $null) -and ($.DriveType -eq “Fixed”)} |
Select-Object DriveLetter
If (($DriveLetters -contains “D”) -or ($DriveLetters -contains “E”) -or ($DriveLetters -contains “F”)) {
The IF fails! Always false that is. If I add -ExpandProperty to the Select-Object statement it works fine.
Without -ExpandProperty
$DriveLetters
DriveLetter
C
With -ExpandProperty - it a simple array and the IF statement works fine.
$DriveLetters
C
Why?? What am I missing here? I’m sure I have missed something very basic while reading Don’s Month of Lunches book.