I found this code on an old thread to shutdown the local machine:
using System.Management; void Shutdown() { ManagementBaseObject mboShutdown = null;
this will work like sharm
gwmi win32_operatingsystem -ComputerName xxxxxxxxxxxx | Invoke-WmiMethod -Name reboot