Laptop Shutdown/Standby/Hibernate Software Script

This is a script I developed to automatically put a laptop running Microsoft Windows 7 into Standby or Hibernate.
I developed this because ShutControl wasn't reliable for me - it would continually corrupt the config file and crash with .NET errors.

The software is provided as-is, and you are free to do whatever with it. No warranties if you break your stuff with it. It works for me and is simple and gets the job done.

Requirements:
Laptop (with a working battery which holds charge for at least 1 minute)
Windows 7 (may work on Vista as well but untested)
Windows Powershell (built into Windows 7)

Preparation:
1. Start Powershell from the start menu as an Administrative User
2. Type the following:

Code:

Set-ExecutionPolicy RemoteSigned
Yes
Exit

3. Close Powershell
4. Start Powershell IME as a regular user
5. Paste the following code into it and save it somewhere such as your Documents folder with the file name Test-IsOnBattery.ps1

6. Test it by clicking on the green Run button. Unplug power for 5 seconds, replug for 5 seconds, unplug for 10 seconds, reconnect power and watch the status messages if you have any problems. The script is well commented to help you troubleshoot.
7. For production use (once you're happy with it), change $DebugMode = $True to $DebugMode = $False
8. Make a shortcut in your Startup folder of your start menu as below and set it to start in a Minimised window:

Code:

powershell.exe <path to Test-IsOnBattery.ps1>

Any queries please feel free to ask and I'll do my best to answer them.
This is the first time I've ever scripted something in Powershell, so please be nice.