by peterhillnl at 2013-03-18 05:19:12
Hi all,by mjolinor at 2013-03-18 05:36:31
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
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
regards,
peter (netherlands)
See if this works better:by peterhillnl at 2013-03-18 07:13:51$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
Thanks Mjolinor, this works great!by mjolinor at 2013-03-18 07:17:02
Now for me to figure out why
Manny thanks again. i’ll get right on it.
It’s the difference between the string value of an object with one property, and the string value of just that one property.