Help with changing drive letters

This topic contains 2 replies, has 3 voices, and was last updated by Profile photo of Stefan Werner Stefan Werner 7 months, 3 weeks ago.

  • Author
    Posts
  • #38106
    Profile photo of Charles Brooks
    Charles Brooks
    Participant

    First I'm new to powershell so my learning has come by google. Have a server with two removable RDX drives. Drive M and N. Need a script to swap the drive letters.

    I came a cross a script for changing the letters, and it works OK, but I have the same issue that I ran into with a VBS script. This runs from windows Scheduler at midnight. If something is access the drive when the swap takes place then it will lock the drive letter so that it is no longer available. Only way I know is to free it by a reboot.

  • #38107
    Profile photo of Don Jones
    Don Jones
    Keymaster

    Yeah, but there's kind of no way around that. Windows locks the drive to keep the accessing process from crashing.

    I'd suggest implementing some kind of post-check in your script. If the mapping didn't work, then the script can schedule itself to try again later. Or, at least email you so that you know to restart the server.

  • #38115
    Profile photo of Stefan Werner
    Stefan Werner
    Participant

    You might be able to write a bit of code to have the script wait while the drive is being accessed before attempting to make the change.

    Different scenario, but worth exploring...
    http://stackoverflow.com/questions/13738236/how-can-i-force-a-powershell-script-to-wait-overwriting-a-file-until-another-pro

    After some thought, Don's idea is likely the better solution.

You must be logged in to reply to this topic.