powershell - Powershell 中用户输入的通配符功能
问题描述
我目前正在编写一个 powershell 脚本,该脚本接受用户输入并搜索目录中具有相似名称的所有项目。
$filename = '*test*.*'
$searchinfolder = 'C:\example'
Get-ChildItem -Path $searchinfolder -Filter $filename -Recurse | %{$_.FullName}
我需要的是让它接受用户输入,同时保持第一行的功能。到目前为止,我使用过:
$filename = Read-Host -Prompt 'Input word'
我必须做些什么来维护功能?例如,它找到文件夹 test 和 test1
解决方案
@Lee_Dailey 在评论中给出了解决方案。
$filename = Read-Host -Prompt 'Input word'
$filename = '*{0}*.*' -f $fileName
Get-ChildItem -Path $searchinfolder -Filter $filename -Recurse | %{$_.FullName}
推荐阅读
- c - 如何制作 EGLStream Hello World?
- java - 找不到能够从类型转换的转换器
- testrigor - 如何让 TestRigor 在页面加载时在浏览器提示中输入密码
- vue.js - 从父组件导航到子组件时,父 Create() 调用了两次
- javascript - 如何在交易视图中使用线条而不是条形
- android - 这种类型的实现怎么称呼?RecyclerView,布局
- javascript - 下次尝试后显示不透明度的脚本不起作用
- web-scraping - 如何以定义的术语分解字符向量?
- c - switch语句c语言的问题
- laravel - 使用 AlpineJS 和 @entangle 指令在 Livewire 中嵌套组件