Here you go.
$RebootList = Get-Content RebootServers.txt
foreach( $Rsrv in $RebootList )
Write-host “Issuing remote reboot command to $Rsrv”
# Command to force reboot the remote server
(gwmi Win32_OperatingSystem -ComputerName $Rsrv).Win32Shutdown(6)
That’s all. You can replace the (6) with any of the following:
0 = Log off
1 = Shutdown
2 = Reboot
8 = Power off
4 = Forced log off
5 = Forced shutdown
6 = Forced reboot
12 = Forced power off
– Thanks, Jinesh.