Bit of a noob powershell question here, I've wrote a script to start a quick backup of a VM that could be scheduled in Task Scheduler & it worked great but I was lazy & hard-coded the VM name into the script meaning to turn it into an argument later.
Finally got around to switching to arguments & wanted to be able to specify multiple VMs for quick-backup (i.e. run at a time 5 mins before a dev is scheduled to do some maintenance. However I've hit an issue where the first arg is read just fine & the quickbackup starts, but then it immediately tries to start the second one, which fails because it's in the same parent backup job.
So, what's the correct way to get further iterations of the quick backups to wait for one to complete before the next one starts?
Fundamentally all I'm doing is a simple:
foreach ($arg in $args)
{
Code for quick-backup
<need some delay/intelligence here>
}
Any pointers to Powershell noob code appreciated
-
- Veteran
- Posts: 600
- Liked: 66 times
- Joined: Jun 13, 2013 10:08 am
- Full Name: Paul Kelly
- Contact:
-
- Veeam Software
- Posts: 1818
- Liked: 655 times
- Joined: Mar 02, 2012 1:40 pm
- Full Name: Timothy Dewin
- Contact:
Re: Quick backup script, wait for first to complete/
maybe you are looking for the wait parameter e.g.:
Code: Select all
Start-VBRQuickBackup -wait
-
- Veteran
- Posts: 600
- Liked: 66 times
- Joined: Jun 13, 2013 10:08 am
- Full Name: Paul Kelly
- Contact:
Re: Quick backup script, wait for first to complete/
Ah, perfect, thanks!
Who is online
Users browsing this forum: Google [Bot] and 9 guests