saving output to file

Hi Guys

 

I’m having this business problem here.

thought I could solve this all by myself but ran into a problem apparently.

 

so the problem is we set up bitlocker for every PC we hand out to end users at the company and saved it to AD. now we noticed that didn’t exactly did the thing.

so I thought i’d write a PS script that saves the key into a file. here is the simple script:

[pre]

$computername = hostname

(Get-BitLockerVolume -mount c).keyprotector | select $computername, keyprotectorId, RecoveryPassword | Out-File -Append -FilePath \someserver\somefolder\somefile.csv

[/pre]

I tested it by myself and worked just fine

now when I ran it for every PC at the office some keys were not complete. example given:

(I changed The values to not disclose confidential data but the issue is visible)

BE-PC0018 KeyProtectorId RecoveryPassword


{2DE34863-5C59-409E-56A7-869AE81CB401}
{8FC79FA8-20A6-4581-9E3E-46C5F57F1F8F} 384483-411151-412654-672969…

 

so as you can see, it did not take the whole recovery key.

is there anyway to bypass this issue?

 

Thanks in advance!

You should use Export-CSV instead of Out-File.

thanks I’ll try it immediatly

 

edit: this works thanks very much!

You can `ConvertTo-Csv` and then write to file…

[pre]

$computername = hostname
(Get-BitLockerVolume -mount c).keyprotector | select $computername, keyprotectorId, RecoveryPassword | ConvertTo-Csv | Out-File -Append -FilePath \someserver\somefolder\somefile.csv

[/pre]

this solution is also working thanks! my problem is solved!

Note that out-file saves as unicode, and most other commands save as ansi.