By concatenating type conversions, you can easily create a list of letters:

 
PS> [Char[]](65..90) 
A
B
C
D 
...  
 

From this list, you can generate a list of drive letters that are in use:

 
PS> [Char[]](65..90) | Where-Object { Test-Path "${_}:\" }
C
D
 

Likewise, to find free (unused) drive letters, try this:

 
PS> [Char[]](65..90) | Where-Object { (Test-Path "${_}:\") -eq $false }
A
B
E
F 
...  
 




Twitter This Tip! ReTweet this Tip!

Anonymous