I'm doing an IF statement in PowerShell and at some point I do this:
(Get-BitlockerVolume -MountPoint "C:").KeyProtector.keyprotectortype
which gives me the results in this format, on top of each other
I want to write my IF statement to check whether the output of the command above contains both "TpmPin" and "RecoveryPassword" but not sure what the correct syntax is.
I tried something like this but it doesn't work as expected, the result is always true even if it should be false.
if ((Get-BitlockerVolume -MountPoint "C:").KeyProtector.keyprotectortype -contains "tpmpin" && "RecoveryPassword")
this doesn't work either:
if ((Get-BitlockerVolume -MountPoint "C:").KeyProtector.keyprotectortype -contains "tpmpinRecoveryPassword")
p.s I don't want to do nested IF statements because I'm already doing multiple of them.

Make the call to
Get-BitLockerVolumebefore theifstatement, store the result in a variable, then use the-andoperator to ensure both are found:If you have an arbitrary number of values you want to test the presence of, another way to approach this is to test that none of them are absent: