locked
Powershell: Check if Locked Driver Exists (BitLocker) RRS feed

  • Question

  • Hello.


    Some users on my company use Dropbox in a portable USB drive, BitLocker encrypted.

    They have to unlock the driver then open dropbox (which they usually forget to).

    So I made a script to unlock it and then open dropbox

    If (!(Test-Path F:))
    {
    ECHO "Desbloqueando o Volume F:"
    manage-bde -unlock F: -pw
    ECHO "Abrindo o Dropbox"
    & 'C:\Program Files (x86)\Dropbox\Client\Dropbox.exe'
    }
    
    Write-Host "Press any key to continue ..."
    
    $x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")

    I would like to insert this script in the startup, using a While and Start-Sleep to check if the driver is present before trying to unlock. Test-Path doesn't seem to work in this scenario since this function gives the same result if the driver is not present or is present but locked.

    Is there a way to do this using powershell?

    Thanks.


    Wednesday, January 10, 2018 5:38 PM

Answers

  • It's not elegant, but I got it Working

    Do {
    $connectedriverSerial = (Get-WmiObject -class Win32_DiskDrive -Filter "SerialNumber = 'XXXX000'" | select-object -expand SerialNumber)
    Start-Sleep -s 2
    }
    Until ($connectedriverSerial -eq 'XXXX000')
    
    
    
    If ($connectedriverSerial -eq 'XXXX000' -and !(Test-Path F:\Dropbox\)) {
    ...


    Wednesday, January 24, 2018 3:47 PM

All replies

  • Use "Get-PsDrive F"

    \_(ツ)_/

    • Marked as answer by oldnewuser Tuesday, January 23, 2018 2:58 PM
    • Unmarked as answer by oldnewuser Wednesday, January 24, 2018 3:35 PM
    Wednesday, January 10, 2018 5:58 PM
  • Sorry, I may be missing something, but it only works after the device is unlocked.

    When I use Get-PSDrive, it doesn't show the locked drive in the list.

    I have to unlock it, close and reopen the Powershell  window,  then it appears.

    Wednesday, January 24, 2018 3:08 PM
  • It's not elegant, but I got it Working

    Do {
    $connectedriverSerial = (Get-WmiObject -class Win32_DiskDrive -Filter "SerialNumber = 'XXXX000'" | select-object -expand SerialNumber)
    Start-Sleep -s 2
    }
    Until ($connectedriverSerial -eq 'XXXX000')
    
    
    
    If ($connectedriverSerial -eq 'XXXX000' -and !(Test-Path F:\Dropbox\)) {
    ...


    Wednesday, January 24, 2018 3:47 PM
  • Hi,

    Good to hear that you have solved this issue by yourself. In addition, thanks for sharing your solution in the forum as it would be helpful to anyone who encounters similar issues.

    If there is anything else we can do for you, please feel free to post in the forum.

    Best Regards,
    Albert

    Please remember to mark the replies as an answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    Thursday, January 25, 2018 1:48 AM