Apologies, I didn't notice until recently that you followed up with another helpful tip. I took your recommendation and changed by code.
For anyone else finding this: This code is very much overly verbose. The excessive error checking can likely be removed. I'm just being overly cautious because this caused me so much drama before Martin helped me figure out what was going on.
Here's the code:
For anyone else finding this: This code is very much overly verbose. The excessive error checking can likely be removed. I'm just being overly cautious because this caused me so much drama before Martin helped me figure out what was going on.
Here's the code:
function FileTransferProgress {
param ($e)
try {
$Filename = $e.Filename
$FileProgress = $e.FileProgress
$CPS = $e.CPS
$OverallProgress = $e.OverallProgress
if ($Filename -match '^[\u0000-\uFFFF]+$') {
# Display progress for ASCII filenames
Write-Progress `
-Id 0 `
-Activity "Synching" `
-Status "$($OverallProgress.ToString('P0')) complete at $CPS bps" `
-PercentComplete ($OverallProgress * 100) `
-CurrentOperation "$Filename - $($FileProgress.ToString('P0'))"
}
else {
Write-Host "The string is not Unicode."
Write-Host "Filename is $Filename"
}
}
catch {
Write-Host "Function: FileTransferProgress"
Write-Host ""
Write-Host ' Attempting Variable Output: $_'
Write-Host $_
Write-Host ""
Write-Host " Additional Error Info:"
Write-Host " Error in script: $($_.InvocationInfo.ScriptName)"
Write-Host " Error on line: $($_.InvocationInfo.ScriptLineNumber)"
Write-Host " Error message: $($_.Exception.Message)"
Write-Host " Error Hit in FileTransferProgress"
Write-Host " Filename: $Filename"
Write-Host " FileProgress: $FileProgress"
Write-Host " CPS: $CPS"
Write-Host " OverallProgress: $OverallProgress"
}
}