Video Screencast Help
Symantec to Separate Into Two Focused, Industry-Leading Technology Companies. Learn more.

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

Created: 05 Aug 2013 • Updated: 06 Aug 2013 | 1 comment
This issue has been solved. See solution.

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:
 
 
Status:  Completed
Return code:  0
   
Start time:  8/5/2013 10:43:32 AM
End time:  8/5/2013 10:43:46 AM
Total run time:  13 seconds

Completed

Output Properties
 
   
Script:  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"?

Operating Systems:

Comments 1 CommentJump to latest comment

Douglas.Dunphy's picture

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.
 
SOLUTION