如何在本机不支持的 powershell 参数中使用通配符?

How to use a wildcard in powershell parameter that doesn't natively support it?

好的,很抱歉这个可能很菜鸟的问题。 我研究 PowerShell 已经有一段时间了,运行 变成了一些我不太清楚如何正确表达 google 的东西。

在最基本的意义上,这就是我正在尝试做的事情。

Get-Process -id 76*

现在我明白了 -id 不会处理通配符 * 字符。 如果我想在理论上使用

Get-Process -id

并为此创建一个通配符脚本,我该怎么做?我需要创建自己的功能吗?

我还想补充一点,PS 特别指出 * 不是 -Name 参数的可用字符,但我可以使用它。这是 MS 的错误吗? 感谢您提前提出任何建议!

在 Get-Process 输出上使用 (Where-Object) filter

在这种情况下:

Get-Process | where { $_.Id -like '76*' }

whereWhere-Object cmdlet 的别名。)