Differences

This shows you the differences between the selected revisions of the page.

2017-02-11 2017-10-03
csharp anchor (martin) using variable expansion in strings in powershell (martin)
Line 153: Line 153:
        $batch = [int]($total / $batches)         $batch = [int]($total / $batches)
-        Write-Host ("Will download {0} files totaling {1} bytes in {2} parallel batches, {3} bytes on average in each" -f $files.Count, $total, $batches, $batch)+        Write-Host "Will download $($files.Count) files totaling $total bytes in $batches parallel batches, $batch bytes on average in each"
               
        $start = 0         $start = 0
Line 166: Line 166:
            if (($sum -ge $batch) -or ($i -eq $files.Count - 1))             if (($sum -ge $batch) -or ($i -eq $files.Count - 1))
            {             {
-                Write-Host ("Starting batch {0} to download {1} files totaling {2}" -f $no, ($i - $start + 1), $sum)+                Write-Host "Starting batch $no to download $($i - $start + 1) files totaling $sum"
                               
                $fileList = $files[$start..$i] -join ";"                 $fileList = $files[$start..$i] -join ";"
Line 189: Line 189:
                    try                     try
                    {                     {
-                        Write-Host ("Starting batch {0}" -f $no)+                        Write-Host "Starting batch $no"
                        # Load WinSCP .NET assembly.                         # Load WinSCP .NET assembly.
Line 201: Line 201:
                        try                         try
                        {                         {
-                            Write-Host ("Connecting batch {0}..." -f $no)+                            Write-Host "Connecting batch $no..."
                            $session = New-Object WinSCP.Session                             $session = New-Object WinSCP.Session
Line 224: Line 224:
                        }                         }
                                               
-                        Write-Host ("Batch {0} done" -f $no)+                        Write-Host "Batch $no done"
                    }                     }
                    catch [Exception]                     catch [Exception]
                    {                     {
-                        Write-Host ("Error: {0}" -f $_.Exception.Message)+                        Write-Host "Error: $($_.Exception.Message)"
                        exit 1                         exit 1
                    }                     }
Line 246: Line 246:
        $ended = Get-Date         $ended = Get-Date
-        Write-Host ("Took {0}" -f (New-TimeSpan -Start $started -End $ended))+        Write-Host "Took $(New-TimeSpan -Start $started -End $ended)"
    }     }
    finally     finally
Line 258: Line 258:
catch [Exception] catch [Exception]
{ {
-    Write-Host ("Error: {0}" -f $_.Exception.Message)+    Write-Host "Error: $($_.Exception.Message)"
    exit 1     exit 1
} }

Last modified: by martin