0

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 使用的帐户是服务器上的本地管理员。

4

1 回答 1

0

你怎么称呼Powershell?当您创建一个 .bat 文件并从那里调用它时,它会修复很多问题,例如,bat 文件包含 1 行 -

powershell -command "& C:\MyPSscripts\archiver.ps1"

看 -

https://communities.bmc.com/thread/117415

于 2017-09-03T14:20:16.950 回答