Advertisement
Guest User

Untitled

a guest
Apr 28th, 2015
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # skripta za backup solidworksa i slanje konfirmacijskog maila
  2. # verzija 1
  3. # autor: vlebo
  4.  
  5. # mail notifikacije prije stopiranja servisa
  6. $hostname = hostname
  7. $smtpServer = 'goemail.goe-group.com'
  8. $from = "administrator@goe-group.com"
  9. $recipients = 'alert@goe-group.com'
  10. $Subject = "Restarting SolidWorks Service on $hostname"
  11. $body = "This is an automated message to confirm that the Solid Works Server service on $hostname  
  12. is about to be restarted as part of scheduled backup, please ignore any alerts  
  13. for the next 30 minutes from this service."
  14.  
  15.  
  16. Send-MailMessage -To $recipients -Subject $Subject -Body $body -From $from -SmtpServer $smtpServer
  17.  
  18. # stopiranje servisa
  19. Stop-Service -Name 'PDMWorks Workgroup Server'
  20. "PDM server stopped"
  21.  
  22. # pokretanje sinhronizacije
  23. & 'C:\Program Files (x86)\Create Software\Create Synchronicity\Create Synchronicity.exe' /run "SWvaultBCK" /log /quiet
  24. "Sync initiated!"
  25. while (Get-Process 'Create Synchronicity' -ErrorAction silentlycontinue) { }
  26.  
  27. # startanje servisa
  28. Start-Service -Name 'PDMWorks Workgroup Server'
  29. "PDM server started!"
  30.  
  31. # Mail konfirmacije da je servis ponovno startan
  32. Start-Sleep -s 5
  33.  
  34. $checkService = Get-Service -Name 'PDMWorks Workgroup Server'
  35.  if ($checkService.Status -ne "Stopped"){
  36. $hostname = hostname
  37. $smtpServer = 'goemail.goe-group.com'
  38. $from = "administrator@goe-group.com"
  39. $recipients = 'alert@goe-group.com'
  40. $Subject = "PDMWorks Workgroup Server started Successfully on $hostname"
  41. $body = "This mail confirms that the PDMWorks Workgroup Server service on $hostname is now running. "
  42.   Send-MailMessage -To $recipients -Subject $Subject -Body $body -From $from -SmtpServer $smtpServer }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement