I have a large VMDK file that has to be broken down into smaller segments to send via website. I have the scripting down to where I split the VMDK into 2GB increments for a total of 30 files. I then put the files together in a string. My problem is taking the string and delimiting it into groups of four and sending them into multiple zip file (website has an 8GB transfer limit). I'm not sure if using and array would be an easier option. New at using Powershell so any advice is welcome.
This is the script I have so far.
function Split-File
{
$inFile = "C:\Users\Justin\Desktop\Split_Test\disk1.vmdk"
([Long]$bufSize = 2000mb)
$stream = [System.IO.File]::OpenRead($inFile)
$chunkNum = 1
$barr = New-Object byte[] $bufSize
$fileinfo = [System.IO.FileInfo]$inFile
$name = $fileinfo.Name
$dir = $fileinfo.Directory
while ($bytesRead = $stream.Read($barr, 0, [Long]$bufsize)) {
$outFile = Join-Path $dir "$name.part$chunkNum"
$ostream = [System.IO.File]::OpenWrite($outFile)
$ostream.Write($barr, 0, $bytesRead)
$ostream.Close()
Write-Host "Wrote $outFile"
$chunkNum += 1
}
$stream.Close()
}
Split-File
I then put the output files into a string using.
$Split = Get-ChildItem C:\Users\Justin\Desktop\Split_Test | Where-Object {$_.Extension -ne ".ps1"}