gpt4 book ai didi

PowerShell 2.0 和 "The term ' Param' 未被识别为 cmdlet、函数、脚本文件或可运行程序的名称”

转载 作者:行者123 更新时间:2023-12-03 11:13:23 30 4
gpt4 key购买 nike

我正在运行 Windows 7 RTM。默认安装 PowerShell 2.0。我正在使用优秀的 Windows PowerShell ISE编辑我的脚本。我有以下脚本:

Param($p)
Param($d)
echo $p $d

我将脚本保存为 SayItAgain.ps1。当我尝试从交互式 shell 运行此脚本时,如下所示:
./SayItAgain -p "Hello"

我收到以下错误:

The term 'Param' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.


At C:\users\cius\Code\powershell\SayItAgain.ps1:2 char:6
+ Param <<<< ($destination)
+ CategoryInfo : ObjectNotFound: (Param:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException

这是一个已知问题还是我只是使用错误?

最佳答案

如果您的 param($p)不是脚本中可能导致参数错误的第一行。

确保您的 param($p)是第一行。

关于PowerShell 2.0 和 "The term ' Param' 未被识别为 cmdlet、函数、脚本文件或可运行程序的名称”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1315140/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com