Digressive / HyperV-Backup-Utility

Flexible Hyper-V Backup Utility
https://gal.vin/posts/vm-backup-for-hyper-v/
MIT License
120 stars 38 forks source link

Errors When No SMTP Authentication #4

Closed eneerge closed 4 years ago

eneerge commented 4 years ago

Thanks for the script. I have found a way to work around this issue, but thought I would mention it.

I've built a script out and when I add the Keep parameter, the script fails to run if you have no smtp authentication.

I tried removing double quotes too to see if that was throwing something off, but that did not work. CreateQuickRestore.cmd

rem Backup Settings
set backupLocation="E:\HyperV\QuickRestore"
set backupsToKeep=1
set vmListFile="E:\HyperV\QuickRestore\BackupScript\vms.txt"
set logFileDir="E:\HyperV\QuickRestore\BackupScript\logs"

rem Email
set emailSubject=Subject Line
set emailSendTo=mail@address.com
set emailFrom=from@address.com
set emailSmtp=smtp.server.com

powershell.exe -executionpolicy unrestricted -file Hyper-V-Backup.ps1 -BackupTo %backupLocation% -List %vmListFile% -Wd %backupLocation% -L %logFileDir% -Subject %emailSubject% -SendTo %emailSendTo% -From %emailFrom% -smtp %emailSmtp% -Keep %backupsToKeep%

Cannot validate argument on parameter 'SmtpPwd'. The "Test-Path -Path $_ -PathType Leaf" validation script for the argument with value "Results" did not return a result of True. Determine why the validation script failed, and then try the command again.

  • CategoryInfo : InvalidData: (:) [Hyper-V-Backup.ps1], ParentContainsErrorRecordException
  • FullyQualifiedErrorId : ParameterArgumentValidationError,Hyper-V-Backup.ps1

Work around is to remove the -Keep parameter and roll my on deletion.

Also, when the keep parameter is removed, the export works, but I get this error at the end of the script.

Cannot convert value "QuickRestore" to type "System.Int32". Error: "Input string was not in a correct format." At E:\HyperV\QuickRestore\BackupScript\Hyper-V-Backup.ps1:261 char:13

  • Get-ChildItem -Path $WorkDir -Filter "$Vm---**--*" -D ...
  • 
    + CategoryInfo          : InvalidArgument: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvalidCastFromStringToInteger

2020-05-03 14:38:54 [INFO] Removing backup folders older than: QuickRestore days

Digressive commented 4 years ago

This isn't really related to this project specifically - but feel free to get in touch with me via email.