【发布时间】:2022-01-22 20:57:25
【问题描述】:
我正在尝试远程运行这段代码:
$servers = @("myserver.local")
Invoke-Command -ScriptBlock {
#############
Write-Host "Test1:" "xxx";
hostname
Write-Host "Test2:" "yyy";
#############
} -ComputerName $servers
得到这个输出:
Test1: xxx
Test1: xxx
myserver
Test2: yyy
Test2: yyy
预期输出:
Test1: xxx
myserver
Test2: yyy
如你所见,Write-Host 的输出翻了一番,但hostname 没问题。
为什么?
【问题讨论】:
-
好像你在 2 个主机上运行这个
-
@Santiago Squarzon 我在 $servers 数组中只有一台服务器。
标签: windows powershell visual-studio-code ps