|
Script to reboot a server and email notify of when it's done
|
|
22-07-2010, 12:37 PM
(This post was last modified: 22-07-2010 12:40 PM by Techmonkey.)
Post: #1
|
|||
|
|||
|
Script to reboot a server and email notify of when it's done
Bit of a long shot, but does anyone know of a program/script that will do the following.
1 - Check the list of services running on a 2003/2008 server. 2 - Send an email to specified address stating that it is about the reboot the server 3 - Reboot the server 4 - Check the list of services now running after reboot, compare against previous list 5 - Email same address confirming reboot and listing any services that have not restarted As I said a long shot I realise
- Techmonkey ================ Enterprise Business IT Support | SME IT Support | Home Support Available |
|||
|
22-07-2010, 12:37 PM
Post: #2
|
|||
|
|||
|
RE: Script to reboot a server and email notify of when it's done
Alternatively does anyone know what language would be the simplest to write this in?
- Techmonkey ================ Enterprise Business IT Support | SME IT Support | Home Support Available |
|||
|
22-07-2010, 01:44 PM
Post: #3
|
|||
|
|||
|
RE: Script to reboot a server and email notify of when it's done
To actually reboot, you could use the command:
shutdown /m \\SERVER_NAME /r /c "Restarting server in 10 seconds" /t10 /m specifies target computer, /r is restart, /c is comment and /t is time (in seconds) till reboot. That can of course be used inside things like batch files, or (not sure what the name is) a script in the new PowerShell. Not sure but maybe this article will help you with the services side of things: http://www.kreslavsky.com/2009/03/manage...32008.html As for the email, I'm sure there are plenty of applications to send from command line, but first one to spring to mind is: http://www.febooti.com/products/command-line-email/ I would imagine you can export the services list into a file, then attach that file with the command line email. That should all be possible through a batch file. Hopefully that points you in the right direction at least, unfortunately I only maintain Linux servers now 8-) Register Linux Machines: 408537, 413272, 413273, 435704, 435721
Arch Linux enthusiast since 2007. Full time user since 2009 |
|||
|
22-07-2010, 04:37 PM
Post: #4
|
|||
|
|||
|
RE: Script to reboot a server and email notify of when it's done
Cheers Jimmy, I will have a look and let you know how I get on.
- Techmonkey ================ Enterprise Business IT Support | SME IT Support | Home Support Available |
|||
|
03-08-2010, 04:09 PM
(This post was last modified: 04-08-2010 12:53 PM by Fail Whale.)
Post: #5
|
|||
|
|||
|
RE: Script to reboot a server and email notify of when it's done
I have been working on a similar script recently to email to the helpdesk all running services prior to and after rebooting a server
What I have so far is the following triggers the reboot and send an email Code: #Script to get running services, email user and reboot computer and leave a tag for a script to run on bootthe first script leaves a text file as a tag which if the next script set to run on boot detects it sends another email with the running services after reboot Code: #script to detect tag from reboot script then get services and send emailAt the moment it does not work quite right as I cannot get the services to display correctly in the emails. To do your comparison between the services running before and after reboot you could possibly store the pre reboot services list in the text file used as a tag then retrieve them in the script which runs on boot up. Quick update to fix the problem with the services not displaying in the email change Code: $services = Get-Service | Where-Object {$_.status -eq "Running"}Code: $services = Get-Service | Where-Object {$_.status -eq "Running"} | Out-StringFollow me on Twitter My Blog Follow me on mFlow Gamertag - Davotronic 5000 |
|||
|
03-08-2010, 05:26 PM
Post: #6
|
|||
|
|||
|
RE: Script to reboot a server and email notify of when it's done
What language is that?
Register Linux Machines: 408537, 413272, 413273, 435704, 435721
Arch Linux enthusiast since 2007. Full time user since 2009 |
|||
|
03-08-2010, 05:32 PM
Post: #7
|
|||
|
|||
|
RE: Script to reboot a server and email notify of when it's done
sorry probably should have mentioned it is Powershell
Follow me on Twitter My Blog Follow me on mFlow Gamertag - Davotronic 5000 |
|||
|
03-08-2010, 06:19 PM
Post: #8
|
|||
|
|||
|
RE: Script to reboot a server and email notify of when it's done
No worries, thought it was
Register Linux Machines: 408537, 413272, 413273, 435704, 435721
Arch Linux enthusiast since 2007. Full time user since 2009 |
|||
|
03-08-2010, 10:22 PM
Post: #9
|
|||
|
|||
|
RE: Script to reboot a server and email notify of when it's done
Nice work Fail Whale, I kind of got side tracked from looking at this, but as soon as poss I will put it back on the agenda.
- Techmonkey ================ Enterprise Business IT Support | SME IT Support | Home Support Available |
|||
|
« Next Oldest | Next Newest »
|

Search
Member List
Calendar
Help





