我想编写一个接受参数并使用函数的powershell脚本。
我试过这个:
param
(
$arg
)
Func $arg;
function Func($arg)
{
Write-Output $arg;
}
但我得到了这个:
The term 'Func' 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 func.ps1:6 char:5
+ Func <<<< $arg;
+ CategoryInfo : ObjectNotFound: (Func:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
好吧,我想。我会试试这个:
function Func($arg)
{
Write-Output $arg;
}
param
(
$arg
)
Func $arg;
但后来,我得到了这个:
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\akina\Documents\Work\ADDC\func.ps1:7 char:10
+ param <<<<
+ CategoryInfo : ObjectNotFound: (param:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
我要求的可行吗?还是我的要求不合理?