Powershell 从远程命令调用获取输出
我有这个简单的代码,可以通过PowerShell远程执行.bat文件Powershell 从远程命令调用获取输出,powershell,batch-file,Powershell,Batch File,我有这个简单的代码,可以通过PowerShell远程执行.bat文件 Invoke-Command -ComputerName servername -Credential $credential -ScriptBlock { Start-Process "\\servername\D$\LocalApp\application\script.bat" } 剧本写得很好。唯一的问题是,我需要能够在CMD窗口执行时看到输出。使用call操作符(&)而不是启动进程: Invoke-Comma
Invoke-Command -ComputerName servername -Credential $credential -ScriptBlock {
Start-Process "\\servername\D$\LocalApp\application\script.bat"
}
剧本写得很好。唯一的问题是,我需要能够在CMD窗口执行时看到输出。使用call操作符(&
)而不是启动进程
:
Invoke-Command -ComputerName servername -Credential $credential -ScriptBlock {
& '\\servername\D$\LocalApp\application\script.bat'
}
或者使用参数-nonewindow
和-Wait
运行启动进程
:
Invoke-Command -ComputerName servername -Credential $credential -ScriptBlock {
Start-Process '\\servername\D$\LocalApp\application\script.bat' -NoNewWindow -Wait
}
使用script.bat生成什么类型的输出?只是“回声”还是别的什么?