SCOM 2012 – restart all SCOM agents in management group

By request, hereby a script which restarts all SCOM 2012 agents in the management group. This is run from for instance a management server. It picks up the names of all agents (not the management servers!) and gets the HealthService of those machines and restarts it. The script does not yet have error handling, but it displays its information as to which machine it is handling currently and what the verbose output is of the restart-service command.
SCOM 2012 – restart all SCOM agents in management group
Enjoy!
Bob Cornelissen