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

Viewing 0 reply threads
  • Author
    Posts
    • #167062
      Participant
      Topics: 7
      Replies: 10
      Points: 74
      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

      <USB_DRIVE>
      <Drive_Name>
      <DRIVE_LETTER>E</DRIVE_LETTER>
      <Serial_Number>4C530000210223101345</Serial_Number>
      </Drive_Name>
      <Drive_Name>
      <DRIVE_LETTER>E</DRIVE_LETTER>
      <Serial_Number>VC0479150805154886000308</Serial_Number>
      </Drive_Name>
      <Drive_Name>
      <DRIVE_LETTER>E</DRIVE_LETTER>
      <Serial_Number>WMC1T0675362</Serial_Number>
      </Drive_Name>
      <Drive_Name>
      <DRIVE_LETTER>F</DRIVE_LETTER>
      <Serial_Number>4C530000210223101345</Serial_Number>
      </Drive_Name>
      <Drive_Name>
      <DRIVE_LETTER>F</DRIVE_LETTER>
      <Serial_Number>VC0479150805154886000308</Serial_Number>
      </Drive_Name>
      <Drive_Name>
      <DRIVE_LETTER>F</DRIVE_LETTER>
      <Serial_Number>WMC1T0675362</Serial_Number>
      </Drive_Name>
      </USB_DRIVE>

       

      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”
      }
      
      }
      
      
Viewing 0 reply threads
  • The topic ‘unlocking bitlocker protected drive not working correctly’ is closed to new replies.