Preserve Directory Structure with Start-BitsTransfer

Preserve Directory Structure with Start-BitsTransfer

I have come across many scenarios when Administrators would like to use BITS to move files and folder between source and destination since it will not use whole bandwidth during move operation. One caveat with BITS is it will not create folders and subfolders inside destination directory. I have created small PowerShell script that combines xcopy.exe to create directory structure, and Start-BitsTransfer cmdlet to transfer files using BITS.

Import-Module BitsTransfer
$source = "C:\MyDir"
$dest = "\\Server\Share\MyDir"
xcopy.exe /T /E $source $dest
Get-ChildItem -Path $source -Directory *.* -Recurse | foreach {$spath = $_.FullName.Remove(0,$source.Length+1); Start-BitsTransfer -Source $source\$spath\*.* -Destination $dest\$spath}
Start-BitsTransfer $source\*.* $dest
Leave a Comment
  • Please add 1 and 7 and type the answer here:
  • Post
Wiki - Revision Comment List(Revision Comment)
Sort by: Published Date | Most Recent | Most Useful
Comments
Page 1 of 1 (1 items)
Wikis - Comment List
Sort by: Published Date | Most Recent | Most Useful
Posting comments is temporarily disabled until 10:00am PST on Saturday, December 14th. Thank you for your patience.
Comments
Page 1 of 1 (1 items)