results from AD (bitlocker password key) no strings

by peterhillnl at 2013-03-18 05:19:12

Hi all,

I am just beginnig to powershell script and have made some nice cut and past things so far but this next problem is
eating me up for more than a week now.

the result of reading the key from active directory (computer) (msfve-recoverypassword ) is not editable like a string

i’ve tried subtring and .replace and .tostring but nothing helps.
what i really want to do is read that key if one is stored in ad, and use it to enable bitlocker
on win7 pc’s that somhow have bitlocker disabled.
or even get a command that random gets a new key, enable bitlocker on c: and store that key in AD
but that i also can’t seem to get done :slight_smile:

with manage-bde -on c: -protectors i have to provide an -ID and i cant use the result $code because it has to much information.


$computer = read-host “Enter computer name”
$comp_dn = (get-adcomputer $computer).distinguishedname
$code= get-adobject -filter ‘objectclass -eq “msFVE-RecoveryInformation”’ -searchbase $comp_dn -properties msfve-recoverypassword |
sort whencreated | select msfve-recoverypassword -last 1

Write-Host “Key in AD:$code” -ForegroundColor blue
#(this shows a key but with some prefix i cant get rid off)

Key in AD]590458-125400-108845-562001-651563-090651-673etc


next i want to:
Write-Host “Key in AD:$code” -ForegroundColor green
cmd /c "c:\windows\sysnative\manage-bde.exe -cn $computer -on c: -adbackup -protectors "
# cmd /c "c:\windows\sysnative\manage-bde.exe -cn $computer -status"


i hope u guys can help me see the light :slight_smile:

regards,

peter (netherlands)
by mjolinor at 2013-03-18 05:36:31
See if this works better:

$computer = read-host “Enter computer name”
$comp_dn = (get-adcomputer $computer).distinguishedname
$code= get-adobject -filter ‘objectclass -eq “msFVE-RecoveryInformation”’ -searchbase $comp_dn -properties msfve-recoverypassword |
sort whencreated | select -ExpandProperty msfve-recoverypassword -last 1

Write-Host “Key in AD:$($code)” -ForegroundColor blue
by peterhillnl at 2013-03-18 07:13:51
Thanks Mjolinor, this works great!
Now for me to figure out why :wink:


Manny thanks again. i’ll get right on it.
by mjolinor at 2013-03-18 07:17:02
It’s the difference between the string value of an object with one property, and the string value of just that one property.