Powershell PSEXEC not working via Control-M

511 views Asked by At

PS Version: 2.0

Hi All,

I am trying to run the batch file from a powershell script using psexec.

The script runs fine while triggering manually or using windows task scheduler; however, powershell get triggered from Control-m but do not complete the part where psexec is used. The rest part of powershell script runs fine.

Below is the function which is not working, besides it do not give any error, it just freezes the script:

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
        }
    }
 }

The account used by Control-M is local admin on the servers.

1

There are 1 answers

0
Mark On

How are you calling the Powershell? When you create a .bat file and invoke it from there it fixes a lot of issues, e.g, bat file contains 1 line -

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

See -

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