powershell - 仅从Get-ChildItem返回目录

标签 powershell

以下查询在PowerShell中搜索文件的位置。有什么方法可以只返回目录而不是目录属性和文件名?

Get-ChildItem -Path C:\random\random -Filter nameofile -Recurse

最佳答案

我假设您只想在此处包含匹配文件的目录名称:

Get-ChildItem -Path C:\random\random -Filter nameofile -Recurse | % { split-path $_.fullname } | sort -uniq

关于powershell - 仅从Get-ChildItem返回目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27530857/

相关文章:

windows - 脚本在Visual Studio中工作,但从批处理文件运行时却不能

powershell - 仅使用 powershell,对包含 300 行的文本文件进行排序,首先按字符串长度排序,然后,一旦达到该长度,按字母顺序设置它们

function - Powershell 隐式转换数组,阻止与 v2 中的 Select -Property 一起使用

regex - 匹配语法问题

powershell - 无法将参数绑定(bind)到参数 'InputObject',因为它为空

Powershell - 单击 div 中的 href 链接

oracle - 在 powershell 中处理 null

powershell - 在 PowerShell shell 的 AZ CLI 中转义双美元符号密码

c# - 创建 C# dll 并使用 powershell 方法

powershell - 基本脚本替换多个目录中的图像文件