Finding Unused Drive Letter

by Aug 23, 2013

Here's a simple way of finding unassigned drive letters:

If you just want any unused drive letter, pipe the result to Get-Random.

This approach uses the fact that PowerShell creates a function for each available drive, so the code tests whether or not there is a function names like a drive letter. If there is, then the drive is taken.

Twitter This Tip! ReTweet this Tip!