Guest User

Untitled

a guest
Dec 7th, 2016
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.06 KB | None | 0 0
  1. powershell -command "& { . C:UsersmslaatsDesktopDatabasescriptsPowershellGmailLibrary.ps1; SendGmail "<email address>" "subject" "body" }"
  2.  
  3. PRINT 'Use the Divestar database'
  4. USE [Divestar]
  5. GO
  6.  
  7. PRINT 'Grant access to execute through a kind of cmd'
  8. EXEC sp_configure 'show advanced options', 1
  9. GO
  10. RECONFIGURE
  11. GO
  12. EXEC sp_configure 'xp_cmdshell', 1
  13. GO
  14. RECONFIGURE
  15. GO
  16.  
  17. -- Delete the old procedure
  18. PRINT 'Drop procedure'
  19. DROP PROCEDURE IF EXISTS [dbo].[SendEmail]
  20. GO
  21.  
  22. -- Procedure --
  23. PRINT 'Create procedure to send an email'
  24. GO
  25. CREATE PROCEDURE [dbo].[SendEmail]
  26. @To VARCHAR(1024),
  27. @Subject VARCHAR(1024),
  28. @Content VARCHAR(1024)
  29. AS
  30. BEGIN
  31. DECLARE @CMD VARCHAR(1024)
  32.  
  33. SET @CMD = 'powershell -command "& { . "C:UsersmslaatsDesktopDatabasescriptsPowershellGmailLibrary.ps1"; SendGmail "<email address>" "onderwerp" "bodytje" }"'
  34. PRINT @CMD
  35.  
  36. EXEC xp_cmdshell @CMD
  37. END
  38. GO
  39.  
  40. . : The term
  41. 'C:UsersmslaatsDesktopDatabasescriptsPowershellGmailLibrary.ps1' is not
  42. recognized as the name of a cmdlet, function, script file, or operable
  43. program. Check the spelling of the name, or if a path was included, verify
  44. that the path is correct and try again.
  45. At line:1 char:7
  46. + & { . C:UsersmslaatsDesktopDatabasescriptsPowershellGmailLibrary.ps1;
  47. Send ...
  48. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  49. + CategoryInfo : ObjectNotFound: (C:Usersmslaat...mailLibrary.p
  50. s1:String) [], CommandNotFoundException
  51. + FullyQualifiedErrorId : CommandNotFoundException
  52.  
  53. SendGmail : The term 'SendGmail' is not recognized as the name of a cmdlet,
  54. function, script file, or operable program. Check the spelling of the name, or
  55. if a path was included, verify that the path is correct and try again.
  56. At line:1 char:77
  57. + & { . C:UsersmslaatsDesktopDatabasescriptsPowershellGmailLibrary.ps1;
  58. Send ...
  59. +
  60. ~~~~
  61. + CategoryInfo : ObjectNotFound: (SendGmail:String) [], CommandNo
  62. tFoundException
  63. + FullyQualifiedErrorId : CommandNotFoundException
  64.  
  65. NULL
Add Comment
Please, Sign In to add comment