Intel,Altiris Group

Expand all | Collapse all

Intel AMT - Failed "Run Script on Task Server" Tasks return code 0 - success

  • 1.  Intel AMT - Failed "Run Script on Task Server" Tasks return code 0 - success

    Posted Aug 05, 2013 03:26 PM

    The Scenario:  My environment is fully configured to execute PowerShell tasks on clients from site servers.  I am using PowerShell to Set and Get the status of the AMT alarm clock.

    The issue I'm having is that the task always shows success - even if the underlying Intel AMT task fails.  

    Here is the "Run Script on Task Server" PowerShell code:

    Import-Module IntelvPro
    New-variable -name amtcred -value (read-AMTCredential)
    Set-AMTAlarmClock %COMPNAME% -Credential $amtcred -AlarmTime:2013-08-05T03:00:00 -Interval:01-00:00:00
     
    If the alarm time is set to a past date, the command will fail.  I'm fully aware of this and have purposefully put the wrong date in the command to make it fail.
     
    Unfortunately, the task reports success and the only way I know it has failed is by opening up the task:
     
     
    <nobr>Status: </nobr> Completed
    <nobr>Return code: </nobr> 0
    <nobr> </nobr>  
    <nobr>Start time: </nobr> 8/5/2013 10:43:32 AM
    <nobr>End time: </nobr> 8/5/2013 10:43:46 AM
    <nobr>Total run time: </nobr> 13 seconds

    Completed



    Output Properties
     
       
    <nobr>Script: </nobr> ComputerName : <redacted>
    Port : 16992
    NextAlarmTime : Monday, August 05, 2013 3:00:00 AM
    PeriodicInterval : P0Y0M01DT00H00M
    Status : Failed

    I haven't yet made the transition to powershell from vbscript.  Does anyone have any tips for getting the status of the Intel AMT PowerShell command to return a failure code to task server when the status returns "Failed"?



  • 2.  RE: Intel AMT - Failed "Run Script on Task Server" Tasks return code 0 - success
    Best Answer

    Posted Aug 06, 2013 08:59 AM

    After a lot of time on the internet and the "Hey, Scripting guy!" blog on Microsoft I was able to figure out how to script this.  This updated code will produce a non-zero exit code to mark the job as failed if it fails:

    $AlarmClockStatus = Set-AMTAlarmClock %COMPNAME% -Credential $amtcred -AlarmTime:2013-08-07T03:00:00 -Interval:01-00:00:00
    If($AlarmClockStatus.Status -eq "Failed") {Exit -1}
     
    The drawback to this method is that the verbose output won't contain the exact error message of a failure, so I recommend fully working out all the kinks in the task before implementing the exit code.