从Powershell列表中选择最后一项 [英] Pick last item from list in Powershell
本文介绍了从Powershell列表中选择最后一项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用此行代码来映射驱动器号,这将为我提供从d到z可用的驱动器列表.
I'm trying to map a drive letter using this line of code which will give me a list of drives available from d to z.
ls function:[d-z]: -n|?{!(test-path $_)}
我想从列表中选择最后一个字母,而不是随机的.我将如何去做? Powershell的新手,谢谢您的帮助.
I'd like to then pick the last letter, not random, from the list. How would I go about doing that? New to Powershell, thanks for the help.
推荐答案
您可以在该管道的末尾使用Select-Object -Last 1
.
You can use Select-Object -Last 1
at the end of that pipeline.
这篇关于从Powershell列表中选择最后一项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文