Run .bat from GPO

LoKkY 211 Reputation points
2020-09-30T16:21:21.757+00:00

Hi,

I'm trying to run a .bat from the machine gpo to save the bitlocker key in AD but it doesn't work.

If I run it locally it works perfectly. All users are local administrators of their machines.

What may be failing?? Other .bat files work without problems

29400-captura.jpg

manage-bde -protectors -get c:  
for /f "skip=4 tokens=2 delims=:" %%g in ('"manage-bde -protectors -get c:"') do set MyKey=%%g  
manage-bde -protectors -adbackup c: -id%MyKey%  

Thanks!!!

Windows for business | Windows Server | User experience | Other
Windows for business | Windows Client for IT Pros | User experience | Other
0 comments No comments
{count} votes

Accepted answer
  1. LoKkY 211 Reputation points
    2020-10-02T21:36:17.317+00:00

    In the end I have achieved it by doing an immediate task as suggested by partner MotoX80

    1 copy the .bat to a folder on the hard disk with a GPO
    2 I schedule an immediate task that executes that script only once and then deletes it

    Thank you very much everyone for the help and forgive all the questions I ask you!!!!!

    I mark this answer as the correct one because it does not let me mark the one of the partner MotoX80 for being a comment.

    0 comments No comments

8 additional answers

Sort by: Most helpful
  1. LoKkY 211 Reputation points
    2020-10-02T07:48:18.37+00:00

    Thank you very much for the answers and sorry for the delay in answering!!!

    MotoX80: I copied the code but the folder c: \ temp does not appear. I don't think the bat is running.

    HannahXiong: Yes, the gpo appears within GPOs applied at the computer level

    29846-captura.jpg

    MTG-6756: I didnt know this, I am going to read your article to see if that could be the problem.

    Thanks!!!!!

    0 comments No comments

  2. LoKkY 211 Reputation points
    2020-10-02T11:19:10.717+00:00

    To sum up:

    The bat works locally and works remotely with psexec.

    gpresult shows the gpo correctly and rsop tb

    I don't know what else to check

    Thanks!!!


  3. LoKkY 211 Reputation points
    2020-10-02T19:05:47.263+00:00

    MTG: 29963-image.png
    29866-image.png

    Works perfectly

    MotoX80: I don't understand your question, the script runs every time the pc starts up.

    I have copied the .bat you wrote and it gives me a syntax error, but at least it creates the temp folder and the .log.
    So what I did was add to my .bat the creation of the temp folder and it works and creates it, but the rest still does not work, it does not save the key in AD

    md c:\temp
    manage-bde -protectors -get c:
    for /f "skip=4 tokens=2 delims=:" %%g in ('"manage-bde -protectors -get c:"') do set MyKey=%%g
    manage-bde -protectors -adbackup c: -id%MyKey%


  4. LoKkY 211 Reputation points
    2020-10-02T19:36:01.03+00:00

    The result of the code that the partner Motox80 wrote is:

    Starting 02/10/2020 21:30:39,47
    Cifrado de unidad BitLocker: versi¢n de la herramienta de configuraci¢n 10.0.18362
    Copyright (C) 2013 Microsoft Corporation. Todos los derechos reservados.
    Volumen C: []
    Todos los protectores de clave
    ERROR: error (c¢digo 0x80070522):
    El cliente no dispone de un privilegio requerido.
    Cifrado de unidad BitLocker: versi¢n de la herramienta de configuraci¢n 10.0.18362
    Copyright (C) 2013 Microsoft Corporation. Todos los derechos reservados.
    ERROR: sintaxis no v lida.
    No se entendi¢ "(c¢digo".
    Escriba "manage-bde -?" para usarla.
    Ending 02/10/2020 21:30:39,79

    Looks like a permission issue....

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.