Data Backup and Recovery

Sending email from Snap Creator Windows Server - how?

mshearer
8,333 Views

I am attempting to send an email form Snap Creator and these commands work from the command line or from a batch file, however when I try to use the command via the event configuration the job gets to the event task and just stops at that point and never returns.  I have tried changing the SC server process to start as a service with a domain account rather than the local system account and have the same behavior.  So has anyone done this before or what exactly am I missing here?  This I would say is a powershell issue, but I am not 100% sure on that and just wanted to see if anyone else has some feedback.  Thank you.

###########################

### Event Configuration ###

###########################

NTAP_ASUP_ERROR_ENABLE=N

SENDTRAP=C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -noprofile -command "& {Send-MailMessage -to mattshearer@lab.stl -from snapcreator@dfm.lab.stl -subject MSG -SmtpServer smtp.lab.stl}"

SUCCESS_TRAP=C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -noprofile -command "& {Send-MailMessage -to mattshearer@lab.stl -from snapcreator@dfm.lab.stl -subject MSG -SmtpServer smtp.lab.stl}"

SUCCESS_MSG=INFO: NetApp Snap Creator Framework Backup for %SNAME ACTION: %ACTION POLICY: %SNAP_TYPE finished successfull

Just to make sure everything was working I confirmed that I could send events to windows events - https://communities.netapp.com/docs/DOC-9247

Notes

SC Version 3.6.0 from the NOW site

Windows Version 2008 R2 Enterprise SP1

1 ACCEPTED SOLUTION

mshearer
8,222 Views

So this is now working and here is the configuration I am using:

How I got this to work:

-Need to have the Snap Creator service started by a domain user rather than local user

-Need to have powershell.exe in your path

-Need to have the < nul at the end of the line of the powershell input

-Have a single tick with a space before and a space after the %MSG and %SUCCESS_MSG variables in the SENDTRAP and SUCCESS_TRAP variables

###########################

### Event Configuration ###

###########################

NTAP_ASUP_ERROR_ENABLE=N

SENDTRAP=powershell.exe -noprofile -command "& {Send-MailMessage -to mattshearer@lab.stl -from snapcreator@dfm.lab.stl -subject ' %MSG ' -SmtpServer smtp.lab.stl}" < nul

SUCCESS_TRAP=powershell.exe -noprofile -command "& {Send-MailMessage -to mattshearer@lab.stl -from snapcreator@dfm.lab.stl -subject ' %SUCCESS_MSG ' -SmtpServer smtp.lab.stl}" < nul

SUCCESS_MSG=INFO: NetApp Snap Creator Framework Backup for %SNAME ACTION: %ACTION POLICY: %SNAP_TYPE finished successfull

View solution in original post

9 REPLIES 9

sivar
8,222 Views

Hello Matt,

Please try to include -Credential<PSCredential> to your powershell script and supply username along with other options.

(like "User01" or "Domain01\User01")

I suspect, snapcreator as such is unable to send emails, and having a domain account like domain\username might break thru.

Thanks,
Siva Ramanathan

Snapcreator Community Moderator

mshearer
8,222 Views

Ok, so I am closer now than I was before, the SUCCESS_TRAP works, the SENDTRAP does not, basically the message needs to be single quoted to be interpreted properly by powershell, so I manually single quoted the SUCCESS_MSG, now trying to figure out how to do that for the MSG variable...

Changes:

-Need to have the Snap Creator service started by a domain user rather than local user

-Need to have powershell.exe in your path

-Had to place single tick quotes around the message in the SUCCESS_MSG variable

###########################

### Event Configuration ###

###########################

NTAP_ASUP_ERROR_ENABLE=N

SENDTRAP=powershell.exe -noprofile -command "& {Send-MailMessage -to mattshearer@lab.stl -from snapcreator@dfm.lab.stl -subject %MSG -SmtpServer smtp.lab.stl}" < nul

SUCCESS_TRAP=powershell.exe -noprofile -command "& {Send-MailMessage -to mattshearer@lab.stl -from snapcreator@dfm.lab.stl -subject %SUCCESS_MSG -SmtpServer smtp.lab.stl}" < nul

SUCCESS_MSG='INFO: NetApp Snap Creator Framework Backup for %SNAME ACTION: %ACTION POLICY: %SNAP_TYPE finished successfull'

sivar
8,222 Views

Awesome!.

SENDTRAP=powershell.exe -noprofile -command "& {Send-MailMessage -to mattshearer@lab.stl -from snapcreator@dfm.lab.stl -subject '%MSG' -SmtpServer smtp.lab.stl}" < nul

Will including the single quotes around %MSG work as you want?

mshearer
8,222 Views

Thanks for the recommendation, yep by placing a single quote on each side with a space I realized it worked and I did not have to make any other special changes, single quote on both sides otherwise made it interpret as a sting i.e. as '%MSG' instead of SNAPCREATOR MESSAGE...

mshearer
8,223 Views

So this is now working and here is the configuration I am using:

How I got this to work:

-Need to have the Snap Creator service started by a domain user rather than local user

-Need to have powershell.exe in your path

-Need to have the < nul at the end of the line of the powershell input

-Have a single tick with a space before and a space after the %MSG and %SUCCESS_MSG variables in the SENDTRAP and SUCCESS_TRAP variables

###########################

### Event Configuration ###

###########################

NTAP_ASUP_ERROR_ENABLE=N

SENDTRAP=powershell.exe -noprofile -command "& {Send-MailMessage -to mattshearer@lab.stl -from snapcreator@dfm.lab.stl -subject ' %MSG ' -SmtpServer smtp.lab.stl}" < nul

SUCCESS_TRAP=powershell.exe -noprofile -command "& {Send-MailMessage -to mattshearer@lab.stl -from snapcreator@dfm.lab.stl -subject ' %SUCCESS_MSG ' -SmtpServer smtp.lab.stl}" < nul

SUCCESS_MSG=INFO: NetApp Snap Creator Framework Backup for %SNAME ACTION: %ACTION POLICY: %SNAP_TYPE finished successfull

sivar
8,222 Views

Thanks much for your efforts in making this work.

I shall discuss this with developers and see if this can be streamlined.  (given that we support various Operating Systems)

debpearenetapp
8,222 Views

Have you made this work with the new version of SanpCreator 4.0p1?

mshearer
8,222 Views

I have not tested this out, but will give it a shot and let you know.

Sudheer
8,203 Views

Hi, thanks for figuring this out. In your script, I dont understand what has to be replaced with "snapcreator@dfm.lab.stl". Include my network email id like snapcreator@xxxx.net ? Please advise.

 

Thanks.

Public