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.
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
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
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.