Auto-shutdown an unused SBA

I’m encountering a growing number of customers upgrading and centralising their Skype for Business infrastructure, and as part of that they’re decommissioning their Survivable Branch Appliances.

At some stage I’ll be asked how they can turn off the SBA, which in the case of the Sonus/Ribbon SBAs is running on a daughter-board inside the appliance (known as the Application Solutions Module or “ASM”). It’s possible to start and stop the SBA from the SBC’s admin interface, but not to turn it off “for good”. Having shut it down, the next time the appliance is power-cycled the daughter-board will spring back to life.

There’s always the option to crack open the box and fish the ASM out, but you’re heading into murky unsupported territory – and you might not want the outage or the pain of wrangling a heavy SBC2k out of its spaghetti mess in the rack and back in again.

PowerShell to the rescue!

Here’s a quick and simple chunk of PowerShell to create a Scheduled Task that automatically shuts the machine down 5 minutes after it powers up. The 5 minutes gives you a chance to login and issue the “shutdown /a” command to cancel said shutdown and disable the Task should you actually wish to use the machine for something.

$TaskName = "Shutdown"
$TaskDesc = "Shuts this machine down to save power & the planet. `n`nAdded by <YourNameHere> on <DATE>"
$TaskAction = New-ScheduledTaskAction -Execute "shutdown.exe" -Argument '/s /t 300 /c "Shutdown by scheduled task" /d p:0:0'
$TaskTrigger = New-ScheduledTaskTrigger -AtStartup
#Now check the task doesn't already exist, and if it's not there, create it:
if (Get-ScheduledTask -taskname "$TaskName" -ea silentlycontinue)
{
write-warning "A task by the name ""$($TaskName)"" already exists"
} else
{
#Create the task:
Register-ScheduledTask –Description $TaskDesc -Action $TaskAction -Trigger $Tasktrigger -TaskName "$TaskName" -TaskPath "Microsoft\Windows" -User "System" -RunLevel Highest | out-Null

write-warning "Created task ""$($TaskName)"" OK"
}

In case you’re wondering, I made the conscious decision NOT to package this up into a script. There’s not a lot to it anyway, and I decided that given what it does I didn’t want to put anyone in the situation where a misplaced double-click could potentially have a vital server going down unexpectedly. So you have to make the conscious decision to copy and paste the above into a P$ window.

… but not on Server 2008

Alas, good ol’ Server 2008 / R2 doesn’t have what it takes to run the ScheduledTask components – not even if you install PowerShell v4. For those old machines you’re going to have to create the Task by hand. It’s not a big deal though, and here are the steps:

  1. Run Task Scheduler
  2. In the Actions pane, click to “Create [A] Basic Task”
  3. Give it a Name and add a Description. (I found I needed to Control-Return to get the line breaks into the Description field)
    1-CreateABasicTask
  4. Click Next
  5. Select “When the computer starts” and click Next
    2-Trigger
  6. Next
    3-Action
  7. Enter “shutdown.exe” for the Program/Script and add the following as the arguments
    /s /t 300 /c "Shutdown by scheduled task" /d p:0:0

    4-StartAProgram

  8. Click Next
  9. Check “Open the Properties dialog…” and click Finish
    5-Finish
  10. Click “Change User or Group” and enter “SYSTEM”, then OK.
    7-SelectUser
  11. Click “Run with highest privileges”. The resulting Properties of the Task should look like this:
    6-Properties
  12. Click OK. You’re done. You can either manually run the task now, or for a proper test, restart the machine. All going well it should stay up for 5 minutes and then shut itself down.

Did it Work? / the Smoking Gun

If you’re looking for confirmation it’s working OK – or you’re chasing rogue shutdowns anywhere else – look for Event 1074 in the System event log:

Event1074-Shutdown

Is it worth it?

Absolutely! I connected the energy meter to my old SBC1000 here and ran some before/after tests. With the first-generation Celeron-based ASM running – idling – the appliance is costing me $110/year to run (at 29c/kWh), and when I turn the ASM off it almost halves to $63.

ASM Running

Cost-ASMRunning

ASM Off

Cost-ASMShutdown

 

You’ve just Built a Useless Box!

So there you have it. You’ve turned a Windows server into a Useless Box! Every time someone turns it on, it turns itself back off again!

 

 

– G.

One Comment

  1. Hi Greg,

    Great solution.
    Another approach could be to have a USB flash drive plugged on the ASM USB port. On this USB you have a small os that shutdown the host when it boot.
    The nice part of this, if you want to restart the ASM, just unplug the flash drive.

    Adrien P.

Leave a Reply

Your email address will not be published. Required fields are marked *

... and please just confirm for me that you're not a bot first: Time limit is exhausted. Please reload the CAPTCHA.

This site uses Akismet to reduce spam. Learn how your comment data is processed.