Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-apps-script/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Powershell 在此处字符串函数中展开时,变量出现错误_Powershell - Fatal编程技术网

Powershell 在此处字符串函数中展开时,变量出现错误

Powershell 在此处字符串函数中展开时,变量出现错误,powershell,Powershell,我刚刚遇到了一个我认为很奇怪的问题,但很可能我只是做错了什么 当我运行此代码时: Function OutOfOrder($animal,$verb,$adjective) { @" The quick brown $animal $verb over the $adjective dog "@ } OutOfOrder("fox","jumped","lazy") 这是我收到的输出: The quick brown fox jumped lazy over the dog PS2.0

我刚刚遇到了一个我认为很奇怪的问题,但很可能我只是做错了什么

当我运行此代码时:

Function OutOfOrder($animal,$verb,$adjective) {
@"
The quick brown $animal $verb over the $adjective dog
"@
}

OutOfOrder("fox","jumped","lazy")
这是我收到的输出:

The quick brown fox jumped lazy  over the  dog
PS2.0和3.0中的行为相同。有什么好处


谢谢

这是一个常见的错误。调用powershell函数时不应使用paren和逗号

您向第一个参数传递了一个由3个字符串组成的数组,而另2个字符串为空

试试这个:

 OutOfOrder "fox" "jumped" "lazy"