Skip to main content

Powershell script to remote reboot servers

$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

*******************************************  
Note:

1. Create a text file – in this case RebootServers.txt
2. Populate RebootServers.txt with the names of the servers you want to reboot. One server name per line. Make sure there are no blank lines after the last server name.
3. Save the RebootServers.txt file in the same directory as the PS1 script (like the one you created – RemoteShutDown.ps1)
4. Run the script to reboot servers.

Comments

Popular posts from this blog

How to configure.NET Framework 3.5 on Windows 8

If  an  utility  requires the .NET framework 3.5, however would not in finding that  version enabled  in your computer, it shows the following message box in Windows 8, both all the way through set up, or while you open the applying for the first time. In the message box, choose Install this feature to enable the .NET Framework 3.5. This option requires an Internet connection. If in case you have ever tried to update the . net   frame work  3.5 from windows features you will get 0x800F0906 or 0x800F081F error . In this article I am showing How to fix . net  framework 3.5 installation in windows 8 or 8.1 error code 0x800f0906  or 0x800F081F.      . NET Framework 4.5 is enabled by default in Windows 8 and Windows 8.1. Windows 8 & Windows 8.1 does not include .NET 3.5 by default, but the files for .NET 3.5 are available on the Wind...

test vpn bandwidth and speed with iperf

This article explains how to use a free utility called iPerf to test the speed of a VPN connection. In this example I am running iPerf on windows but there are other versions available (i.e. Linux). Download iPerf from  http://linhost.info/2010/02/iperf-on-windows/ Put a copy on 2 computers with 1 either side of the VPN. In this example I have put in the c:\triangle folder On the “server” PC open a cmd prompt and navigate to the folder containing iperf. Note on computers running Win7 or Win2008 I recommend running the cmd prompt in elevated mode. Run the command  iperf –s On the “client” PC open a cmd prompt and again navigate to the folder containing iperf. Run the command  iperf –c After a short while the estimated bandwidth is displayed.

Installing Nagios 4 on Ubuntu 14 04 LTS