PS版本: 2.0
大家好,
我正在尝试使用psexec从powershell脚本运行批处理文件。
该脚本在手动触发或使用windows任务调度程序时运行良好;但是,powershell从Control-m触发,但不会完成使用psexec的部分。powershell脚本的其余部分运行良好。
下面是不工作的函数,除了它没有给出任何错误,它只是冻结了脚本:
function Archive_Logs($Server_Name,$Tool_Path,$Name)
{
foreach($TPath in $Tool_Path){
C:\Windows\System32\PsExec.exe \\$Server_Name "$TPath\ziplogs.bat"
if($LastExitCode -eq 0)
{
"$Name Server logs archive Started successfully at $(Get-Date)" | Out-File $LOGFILE -Append
}
}
}Control-M使用的帐户是服务器上的本地管理员。
发布于 2017-09-03 22:20:17
你怎么给Powershell打电话?当您创建一个.bat文件并从那里调用它时,它修复了许多问题,例如,bat文件包含1行-
powershell -command "& C:\MyPSscripts\archiver.ps1“
请看-
https://stackoverflow.com/questions/45965186
复制相似问题