获得免费驱动器号 [英] Getting a free drive letter

查看:36
本文介绍了获得免费驱动器号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 这个答案 我想知道是否有更有效的方法来做到这一点.似乎链接答案中的函数会继续遍历所有字母,即使它已经找到了一个可用的驱动器号.

I saw the Get-NextFreeDrive function in this answer and I wondered if there was a more efficient way to do this. It appears that the function in the linked answer keeps going through all the letters even if it has already found a free drive letter.

推荐答案

在 PowerShell Magazine,我们举办了一场脑筋急转弯比赛,以找出您问题的最短答案.检查这个:

At PowerShell Magazine, we ran a brain teaser contest to find out the shortest answer to your question. Check this:

http://www.powershellmagazine.com/2012/01/12/find-an-unused-drive-letter/

有几个答案,但这是我最喜欢的一个:

There are several answers but here is my fav one:

ls function:[d-z]: -n | ?{ !(test-path $_) } | random

这篇关于获得免费驱动器号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆