Guest User

Untitled

a guest
Apr 28th, 2015
221
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. $recipients = '[email protected]'
  9. $Subject = "Restarting SolidWorks Service on $hostname"
  10. $body = "This is an automated message to confirm that the Solid Works Server service on $hostname  
  11. is about to be restarted as part of scheduled backup, please ignore any alerts  
  12. for the next 30 minutes from this service."
  13.  
  14.  
  15. Send-MailMessage -To $recipients -Subject $Subject -Body $body -From $from -SmtpServer $smtpServer
  16.  
  17. # stopiranje servisa
  18. Stop-Service -Name 'PDMWorks Workgroup Server'
  19. "PDM server stopped"
  20.  
  21. # pokretanje sinhronizacije
  22. & 'C:\Program Files (x86)\Create Software\Create Synchronicity\Create Synchronicity.exe' /run "SWvaultBCK" /log /quiet
  23. "Sync initiated!"
  24. while (Get-Process 'Create Synchronicity' -ErrorAction silentlycontinue) { }
  25.  
  26. # startanje servisa
  27. Start-Service -Name 'PDMWorks Workgroup Server'
  28. "PDM server started!"
  29.  
  30. # Mail konfirmacije da je servis ponovno startan
  31. Start-Sleep -s 5
  32.  
  33. $checkService = Get-Service -Name 'PDMWorks Workgroup Server'
  34.  if ($checkService.Status -ne "Stopped"){
  35. $hostname = hostname
  36. $smtpServer = 'goemail.goe-group.com'
  37. $recipients = '[email protected]'
  38. $Subject = "PDMWorks Workgroup Server started Successfully on $hostname"
  39. $body = "This mail confirms that the PDMWorks Workgroup Server service on $hostname is now running. "
  40.   Send-MailMessage -To $recipients -Subject $Subject -Body $body -From $from -SmtpServer $smtpServer }
Advertisement
Add Comment
Please, Sign In to add comment