The operation has timed out

Hello, I am looking to send myself a log file at the end of every month that shows my VPN connections for that month

Here it grabs the file and then sends it as an attachment. The file is 27MB The only problem is it always says:

Send-MailMessage : The operation has timed out.
At C:\VPNSCRIPT.ps1:3 char:1
+ Send-MailMessage -SMTPserver XXXXXXXXXX -From n ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (System.Net.Mail.SmtpClient:SmtpClient) [Send-MailMessage], SmtpException
    + FullyQualifiedErrorId : SmtpException,Microsoft.PowerShell.Commands.SendMailMessage

$date = get-date -Format "IN15MM"
Send-MailMessage -SMTPserver XXXXXXXXX -From XXX@XXXXX.com -Subject "VPN LOG" -To XXX@XXXXX.com -Attachments C:\$date.log

July 20th, 2015 10:39am

The log file is likely too big.  Most mail servers limit at 10Mb.

Free Windows Admin Tool Kit Click here and download it now
July 20th, 2015 10:51am

Thats what I was afraid of. Would it be possible to create a script that grabs a file then zips it then sends it?

July 20th, 2015 11:02am

Thats what I was afraid of. Would it be possible to create a script that grabs a file then zips it then sends it?

Most everything is possible. There are threads around here that go through how to use .Net 4.5's ZipFile class for creating zip files.
Free Windows Admin Tool Kit Click here and download it now
July 20th, 2015 11:22am

Thats what I was afraid of. Would it be possible to create a script that grabs a file then zips it then sends it?

You can use free tools in your script to make a zip file. For example 7zip


        ...
	$arc="C:\Program Files\7-Zip\7z.exe"
        $arc_params="a -t7z -m0=LZMA2 -mmt -mx9"
        $arc_source="$VolumeTarget\$newname"
        $arc_dest="$Path2Arc\$newname.7z"
        Write-Verbose "Zip folder $newname to  $newname.7z"
        Start-Process $arc -ArgumentList "$arc_params $arc_dest $arc_source" -Wait
	...

July 24th, 2015 4:54am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics