Description
The PowerShell script (below) sends an email using SMTP attributes passed on the command-line (i.e. from-Email-Address, to-Email-Address, and SMTP-Server). The script then pauses for 5 minutes before returning control to the Delphix Engine.
Source Code for Script
Downloadable copy email_5mins.ps1.
Description The PowerShell script (below) sends an email using SMTP attributes passed on the command-line (i.e. from-Email-Address, to-Email-Address, and SMTP-Server). The script then pauses for 5 minutes before returning control to the Delphix Engine. Source Code for Script Downloadable copy email_5mins.ps1. #================================================================================ # File: email_5mins.ps1 # Type: powershell script # Author: Delphix Professional Services # Date: 04-Nov 2016 # # Copyright and license: # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. # # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" basis, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # # See the License for the specific language governing permissions and # limitations under the License. # # Copyright (c) 2015,2016 by Delphix. All rights reserved. # # Description: # # Script will send an email using the SMTP attributes passed as parameters # on the command-line, and then pause for 5 minutes. # # # Command-line parameters: # # fromEmailAddr - originating email address (used for "reply-to") # toEmailAddr - destination email address # smtpServer - IP address or hostname of SMTP server # opName - free-format text describing the Delphix operation # about to occur (i.e. "REFRESH", "REWIND", "STOP", etc) # # # Environment inputs expected: # # VDB_DATABASE_NAME # # Note: # # Modifications: # TGorman 04nov16 first version #================================================================================ param( [string]$fromEmailAddr = "~~~" ,[string]$toEmailAddr = "~~~" ,[string]$smtpServer = "~~~" ,[string]$opName = "~~~" ) # #-------------------------------------------------------------------------------- # Compose the email within a "Net.Mail.MailMessage" object, then send it... #-------------------------------------------------------------------------------- $message = New-Object Net.Mail.MailMessage $message.From = $fromEmailAddr $message.To.Add($toEmailAddr) $message.Subject = "VDB '" + $env:VDB_DATABASE_NAME + "' will be " + $opName + " in 5 mins" $message.Body = "<H1>Delphix operation " + $opName + " will occur in 5 mins</H1>" $message.Body = $message.Body + "<BR><BR>Please save any work in this database or it will be lost." $message.Body = $message.Body + "<BR><BR>Contact IT Operations at x5555 if you have any questions or concerns" $message.IsBodyHTML = "True" $smtp = New-Object Net.Mail.SmtpClient($smtpServer) $smtp.Send($message) # #-------------------------------------------------------------------------------- # Go to sleep for 300 seconds (5 minutes)... #-------------------------------------------------------------------------------- Start-Sleep -s 300 exit 0 Related Topics Cookbook of Common