我有'computers.txt'中的计算机列表。如何在列表上运行命令并让PsExec或Powershell自动跳转到此列表上的下一个项目
我想在列表中的每个远程计算机名称上运行一个.exe。我必须在每台正确安装.exe的计算机上执行.ps1脚本。在PsExec中,我必须在每个计算机名称之间的一分钟或2分钟之后按回车。这将通过远程计算机列表并运行每台计算机上的.exe。 在PowerShell中,只有第一台计算机运行.exe,其余的则不执行任何操作。
有没有什么办法可以在脚本运行时不需要在计算机名称之间按下Enter来完成列表?我希望它能够自动运行。
这是我在PsExec中使用的。
psexec -s @C:\App\computers.txt cmd /c "Powershell Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Bypass && PowerShell -noninteractive -file "C:\SpeedInstall.ps1""
以下是我在PowerShell中
我试图$a = Get-Content "C:\App\computers.txt"
foreach($line in $a) {
psexec -s \\$line cmd /c "Powershell Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Bypass && PowerShell -noninteractive -file C:\SpeedInstall.ps1"
}