VMware Cloud Community
Gonzouk
Enthusiast
Enthusiast

Snapshot script error

Hello,

I've been trying to run this snapshot powercli script and it has been working, but recently stopped.  We get the email, but no body in the email.

##These are the properties assigned to the table via the ConvertTo-HTML cmdlet

$tableProperties = "<style>"

$tableProperties = $tableProperties + "TABLE{border-width: 1px;border-style: solid;border-color: black;}"

$tableProperties = $tableProperties + "TH{border-width: 1px;padding: 5px;border-style: solid;border-color: black;}"

$tableProperties = $tableProperties + "TD{text-align:center;border-width: 1px;padding: 5px;border-style: solid;border-color: black;}"

$tableProperties = $tableProperties + "</style>"

##The script automatically connects to the server if needed. The $server variable needs to

#be changed if the server name changes. (Change <yourServerName> to the name of your

#vSphere server!)

$server = "svr-vcenter-01"

If (!(connect-viserver $server -ErrorAction SilentlyContinue).IsConnected)

{

Write-Host "Connecting to server:" $server

connect-viserver $server -ErrorAction SilentlyContinue -ErrorVariable err

If($err)

{

Write-Host "Error in connecting to server, please check server name." -ForegroundColor Red

break

}

Write-Host "   Complete" -ForegroundColor Green

}

##Main##

Write-Host "Looking for snapshots"

$date = get-date

$datefile = get-date -uformat '%d-%m-%Y-%H%M%S'

$filename = "C:\vmware\powercli\reports\VMwareSnapshots_" + $datefile + ".htm"

##Get VM's, look for snapshots on those VM's. This takes a while because the get-vm cmdlet

#is not quick.

$ss = Get-vm | Get-Snapshot

Write-Host "   Complete" -ForegroundColor Green

Write-Host "Generating snapshot report"

$ss | Select-Object vm, name, description, created | ConvertTo-HTML -head $tableProperties -body "<th><font style = `"color:#000000`"><big><b>VMware Snapshots</b></big></font></th>"  | Out-File $filename

Write-Host "   Complete" -ForegroundColor Green

Write-Host "Your snapshot report has been saved to:" $filename

##Send email with generated report attached##

Write-Host "Sending email with report:" $filename + "attached"

Send-Mailmessage -from "vmware-reports <vmware-snap-reports@exterionmedia.co.uk>" -to "test <test@mycomapnay.co.uk>" -subject "Virtual Machines with snasphots" -body "VMware report attached: VMs with snapshots" -Attachment $filename -priority High -dno onSuccess, onFailure -smtpServer smtp.test.local

if I run in powercli  the error is:

Send-MailMessage : Error in processing. The server response was: 4.7.0 Temporary server error. Please try again later. PRX4 At C:\VMware\powercli\get-snapshot-script.ps1:46 char:17

This 46:char:17 relates to just before -from:

Send-Mailmessage (here)-from

0 Kudos
1 Reply
sajal1
Hot Shot
Hot Shot

HI,

This is typically an error from the Mail server (I suppose you have Exchange server in your environment). Check the following links:

https://social.technet.microsoft.com/Forums/exchange/en-US/6218870f-f67f-4655-bd03-68b8fa722fc2/the-...

The server response was: 4.7.0 Temporary server error. Please try again later. PRX3 - Stack Overflow

So check at Mail server end.

Let me know if it solves your problem

0 Kudos