Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

ForEach Parallel doing VM Backups with TSM

$
0
0

Hi guys, Storage admin here.

Wonder if you could help me with the following Powershell workflow. The objective is to run a backup per VM and wait for the result code to check if it needs to be re-run.

This is what I have until now:

workflow VMincrBKP{
    $VMlist = Get-Content -LiteralPath C:\SCRIPTS\VMLIST.txt
    foreach -parallel ($VM in $VMlist){
        $Tries=0
        do
        {
        $Tries++
        "###### Try number $Tries ######"
        $Time = Get-Date
        $Retries = 3
        $Backup = Start-Process -PassThru -FilePath dsmc.exe -ArgumentList "backup vm $VM -asnode=ASNODE -mode=IFIncr -optfile=C:\SCRIPTS\dsm.opt -preview" -WorkingDirectory "C:\Program Files\Tivoli\TSM\baclient" -Wait
        $Result = $Backup.ExitCode
        "####### Success $Result ######"
                        
        }until (($Tries -eq $Retries) -or ($Result -le 8))
        "####### Total Tries $Tries ######"
            }
    
}

When I call this workflow I get the following:

PS C:\> VMincrBKP
###### Try number 1 ######
###### Try number 1 ######
###### Try number 1 ######
####### Success  ######
###### Try number 2 ######
####### Success  ######
###### Try number 2 ######
####### Success  ######
###### Try number 2 ######
####### Success  ######
###### Try number 3 ######
####### Success  ######
###### Try number 3 ######
####### Success  ######
###### Try number 3 ######
####### Success  ######
####### Success  ######
####### Total Tries 3 ######
####### Total Tries 3 ######
####### Success  ######
####### Total Tries 3 ######

The list contains 3 VM names, two exist and work fine but the third one should fail because it doesn't exist.



Viewing all articles
Browse latest Browse all 21975

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>