unlocking bitlocker protected drive not working correctly

Welcome Forums General PowerShell Q&A unlocking bitlocker protected drive not working correctly

This topic contains 0 replies, has 1 voice, and was last updated by  acer460527 2 months ago.

  • Author
    Posts
  • #167062

    Participant
    Topics: 5
    Replies: 7
    Points: 46
    Rank: Member

    Dear all

    the purpose of this script is to unlock bitlocker encrypted drives attached to my machine at logon.
    I've got this xml



    E
    4C530000210223101345


    E
    VC0479150805154886000308


    E
    WMC1T0675362


    F
    4C530000210223101345


    F
    VC0479150805154886000308


    F
    WMC1T0675362

     

    and use this a base config file for each external drive that I can attach to my machine

    I've got this script worked out only there is just 1 device being unlocked even when there are 2 out of possible 3 connected to the computer
    can you help me out to see what I need to adapt to make it work that if it finds 1 it also continue to unlock the second and 3rd

     

    
    $Base_DIR=(resolve-path .\).Path
    $ddMMyyyy=(get-date).ToString('dd-MM-yyyy');
    $LOG_DIR= $Base_DIR + "\LogFolder"
    $LOG_File = $LOG_DIR + "\unlock"+ $ddMMyyyy + ".log"
    $xml_config =$Base_DIR + "\Usb.xml"
    [xml]$xml_content = Get-Content $xml_config
    
    foreach($entity in $xml_content.GetElementsByTagName("Drive_Name")){
    $Drive = $entity.DRIVE_LETTER
    $serial = $entity.Serial_Number
    $drive_serialnumber = Get-Partition -DriveLetter $Drive | Get-Disk | select-object -ExpandProperty SerialNumber
    $drive_serialnumber.trim()
    
    if($drive_serialnumber.trim() -like $serial){
    .\unlock8gb.ps1
    write-host "Drive succesfully unlocked"
    }else {
    .\Unlock64gb.ps1
    write-host "Drive succesfully unlocked"
    }
    
    }
    
    

You must be logged in to reply to this topic.