0

This is most likely going to be a very simple fix but its something I am trying to get my head around when it comes to the select keyword. How do I simply return the value 'On' from the below script:

$bitlockerStatus = Invoke-Command -ComputerName $computer {Get-BitLockerVolume | select ProtectionStatus -First 1}

$bitlockerStatus 

It returns:

ProtectionStatus PSComputerName RunspaceId                          
---------------- -------------- ----------                          
On               MKC-06981      *confidential*

I have used the select statement before to return the value but I cant understand why in this case it isn't working. I need it to return 'on' or 'off' so I can use it in a String comparison.

Thanks

mcgirlja
  • 167
  • 3
  • 13
  • 2
    Using [member-access enumeration](https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_member-access_enumeration): `(Get-BitLockerVolume).ProtectionStatus` – iRon Aug 22 '22 at 11:50

1 Answers1

1

Use the -ExpandProperty parameter with Select-Object to expand just the value of a particular property:

... |Select-Object -ExpandProperty ProtectionStatus -First 1
Mathias R. Jessen
  • 157,619
  • 12
  • 148
  • 206