VisibleExternalCommands 中的通配符在 PSSessionConfiguration 中不起作用

Wildcards in VisibleExternalCommands not working in PSSessionConfiguration

我正在尝试在 VisibleExternalCommands 中为 New-PSSessionConfigurationFile 使用像 "c:\scripts\*.ps1" 这样的通配符,生成的 .pssc 文件看起来很好,但不能让它按预期工作,而且这里的文档很薄弱。我只能通过提供完整路径来使 VisibleExternalCommands 工作。

重现步骤,在 Win10 上使用 PowerShell 5.1 测试:

设置目录和脚本:

Enable-PSRemoting -Force
mkdir c:\scripts
echo "Write-Output hello" | Out-File c:\scripts\hello.ps1 -Force
echo "Write-Output world" | Out-File c:\scripts\world.ps1 -Force

使用通配符(不工作):

New-PSSessionConfigurationFile -VisibleExternalCommands "c:\scripts\*.ps1" -Path c:\scripts\TestWildcard.pssc -SessionType RestrictedRemoteServer -LanguageMode FullLanguage
Register-PSSessionConfiguration -Name TestWildcard -Path c:\scripts\TestWildcard.pssc -Force
Invoke-Command . -ConfigurationName TestWildcard {c:\scripts\hello.ps1; c:\scripts\world.ps1}
# Fails to recognize both .ps1 scripts as external commands

使用完整路径(工作正常):

New-PSSessionConfigurationFile -VisibleExternalCommands "c:\scripts\hello.ps1" -Path c:\scripts\TestFullPath.pssc -SessionType RestrictedRemoteServer -LanguageMode FullLanguage
Register-PSSessionConfiguration -Name TestFullPath -Path c:\scripts\TestFullPath.pssc -Force
Invoke-Command . -ConfigurationName TestFullPath {c:\scripts\hello.ps1; c:\scripts\world.ps1}
# Prints hello and fails to recognize c:\scripts\world.ps1

文档 (https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/new-pssessionconfigurationfile?view=powershell-5.1) 说支持通配符,但没有显示任何示例。

我是不是遗漏了什么或者这是一个错误?

VisibleExternalCommands 选项不接受通配符。此文档错误已在 https://github.com/MicrosoftDocs/PowerShell-Docs/issues/4756.

中修复