tonyd
September 17, 2021, 5:34pm
1
Not sure how to ask this question. If I do this, I get nothing:
$info = Invoke-Command -ComputerName 'MYCOMPUTER' -ScriptBlock {Get-BitlockerVolume -MountPoint 'C:'}
$info.Keyprotector.RecoveryPassword
However, if I do this, I get results:
$info = Invoke-Command -ComputerName 'MYCOMPUTER' -ScriptBlock {(Get-BitlockerVolume -MountPoint 'C:').Keyprotector.RecoveryPassword}
$info
I would like to use the former versus the later. Any ideas on how to make that work?
Thanks in advance.
What does $info | Get-Member show? A string or an object?
tonyd
September 17, 2021, 7:37pm
3
It appears to be an object:
PS C:\WINDOWS\system32> $info.GetType()
IsPublic IsSerial Name BaseType
-------- -------- ---- --------
True True PSObject System.Object
I should point out that I only see this behavior when I query remote systems using Invoke-Command. Everything local works fine.
tonyd
September 17, 2021, 10:58pm
5
Sorry about that Krazy Doug
TypeName: Deserialized.Microsoft.BitLocker.Structures.BitLockerVolume
Name MemberType Definition
GetType Method type GetType()
ToString Method string ToString(), string ToString(string format, System.IFormatProvider formatPro…
PSComputerName NoteProperty string PSComputerName=MYCOMPUTER
PSShowComputerName NoteProperty bool PSShowComputerName=True
RunspaceId NoteProperty guid RunspaceId=712fcebf-4af3-4652-b46a-1b52e8e71e11
AutoUnlockEnabled Property {get;set;}
AutoUnlockKeyStored Property System.Boolean {get;set;}
CapacityGB Property System.Single {get;set;}
ComputerName Property System.String {get;set;}
EncryptionMethod Property System.String {get;set;}
EncryptionPercentage Property System.Single {get;set;}
KeyProtector Property Deserialized.System.Collections.ObjectModel.ReadOnlyCollection`1[[Microsoft.BitLoc…
LockStatus Property System.String {get;set;}
MetadataVersion Property System.Int32 {get;set;}
MountPoint Property System.String {get;set;}
ProtectionStatus Property System.String {get;set;}
VolumeStatus Property System.String {get;set;}
VolumeType Property System.String {get;set;}
WipePercentage Property System.Single {get;set;}
I see the Keyprotector property, but it is empty.
Hmm that is odd. I’ll have to find a test system.
Hello Tonyd,
I think that’s the deserialized object problem.
when you use the invoke-command you will get a deserialized object and it is not the real object.
you can enter $info.Keyprotector|gm
to check.
when you use invoke-command, the type is System.String
And it dosen’t has the RecoveryPassword property. so you get the empty value.
if you don’t use the invoke-command,
The type of this object is Microsoft.BitLocker.Structures.BitLockerVolumeKeyProtector
then you can get the RecoveryPassword property.
so you must put “get Keyprotector.RecoveryPassword” into the -ScriptBlock {}.
1 Like
Overlooked deserialized. Great call.
tonyd
September 18, 2021, 3:27pm
10
Chen,
Thank you. I will use the second method I posted. Although not desired, I guess I am stuck with it.
Thank you both for the help