Jump to content

Recommended Posts

Posted

I recently had a need to know if my windows update scheduling was working on my servers.

 

I cobbled together a startup script to send an e-mail to myself. This was just a quick and dirty method that took no time at all. I realise if I had more time there are better ways of doing this without resorting to third party tools etc.

 

set hostname="C:\WINDOWS\system32\hostname.exe"
%hostname% > %hostname_results%#
for /f "tokens=1" %%x in (%hostname_results%#) do (set host=%%x)
del /f /q # > nul 2>&1
\\domain.sch.uk\SYSVOL\domain.sch.uk\scripts\blat.exe -to [email protected] -f [email protected] -server smtp.mailserver.org -s "Server %host% rebooted" -body "This server has been rebooted possibly to unstall updates"

 

Credit for the clever bit to add the hostname from Packetwatch Research

You will need to download BLAT and copt it to a share (used sysvol for no real reason)

 

You could add blat to a folder in your path such as c:\windows \system32 if you wish

I then just used a GPO to add a startup script for the servers in the correct OU

Posted

You could have used a PowerShell script at start-up to do exactly the same thing

$Computername = (Get-Childitem env:computername).Value
Send-MailMessage -To "[email protected]" -From "[email protected]" -Subject "Server $Computername Rebooted" -Body "This server has been rebooted, possibly to install some updates" -SmtpServer "smtp.mailserver.org"

  • Thanks 1
  • 2 years later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...