【发布时间】:2019-12-01 00:41:45
【问题描述】:
通过使用 (get-command Oscdimg).Path ,我能够检索完整路径。
这是我得到的:D:\Windows Kits\10\Assessment and Deployment Kit\Deployment Tools\amd64\Oscdimg\oscdimg.exe
我真正想要的是:D:\Windows Kits\10\Assessment and Deployment Kit\Deployment Tools\amd64\Oscdimg
我不希望 oscdimg.exe 在我的路径中。有什么方法可以去除吗?
【问题讨论】:
-
你的意思是Get-ChildItem吗?在这种情况下,您可以执行 $DirectoryName = (Get-ChildItem 'D:\Windows Kits\10\Assessment and Deployment Kit\Deployment Tools\amd64\Oscdimg\oscdimg.exe').DirectoryName
-
@phiz 是的,它有效。非常感谢。
标签: powershell