Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/11.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,我想了解如何将PowerShell中某些程序的输出重定向到文件。 在cmd中,我曾经这样做: some.exe > test.in .\some.exe > test.in 在这样的PowerShell中: some.exe > test.in .\some.exe > test.in 但是这个代码不起作用: for($i = 0; $i -le 5; $i++) { & '.\some.exe > test.in' } 那么,你能告诉我,我应

我想了解如何将PowerShell中某些程序的输出重定向到文件。 在cmd中,我曾经这样做:

some.exe > test.in
.\some.exe > test.in
在这样的PowerShell中:

some.exe > test.in
.\some.exe > test.in
但是这个代码不起作用:

for($i = 0; $i -le 5; $i++)
{
  & '.\some.exe > test.in'
}

那么,你能告诉我,我应该怎么做才能让它工作吗?

这里有一个有效的例子

for($i = 0; $i -le 5; $i++)
{
    nslookup.exe www.google.com | findstr "Addresses:" >> test.in
}

下面是一个有效的例子

for($i = 0; $i -le 5; $i++)
{
    nslookup.exe www.google.com | findstr "Addresses:" >> test.in
}