|
|
@@ -32,6 +32,7 @@ Function WinDD($inFileName, $outFileName, $bs = 5Mb, $create = $false) {
|
|
|
$blocksize = $bs
|
|
|
$block = [System.Byte[]]::CreateInstance([System.Byte], $bs)
|
|
|
|
|
|
+ $position = 0
|
|
|
try{
|
|
|
if ($create){
|
|
|
$filemode = [System.IO.FileMode]::OpenOrCreate
|
|
|
@@ -70,6 +71,7 @@ Function WinDD($inFileName, $outFileName, $bs = 5Mb, $create = $false) {
|
|
|
$blocksize = $inFile.Read( $block, 0, $bs)
|
|
|
|
|
|
$outFile.Write( $block , 0, $blocksize) | Out-Null
|
|
|
+ $position = $outFile.Position
|
|
|
|
|
|
$percent = [math]::Min(100,[math]::Round(100 * $outFile.Position / $inFileLength, 1))
|
|
|
$done = [math]::Round($outFile.Position/1Mb)
|
|
|
@@ -84,17 +86,21 @@ Function WinDD($inFileName, $outFileName, $bs = 5Mb, $create = $false) {
|
|
|
|
|
|
} catch {
|
|
|
|
|
|
- $ex = $_.Exception
|
|
|
+ "Exception at $position"
|
|
|
+ $_.Exception
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
- $inFile.Close()
|
|
|
|
|
|
try {
|
|
|
+ $inFile.Close()
|
|
|
$outFile.Close()
|
|
|
} catch {
|
|
|
+
|
|
|
+ "Exception while closing"
|
|
|
+ $_.Exception
|
|
|
}
|
|
|
- if ($ex -ne $null){throw $ex}
|
|
|
+ Write-Output "Closed!"
|
|
|
}
|
|
|
|
|
|
} #end function WinDD
|