Skip to content

Instantly share code, notes, and snippets.

@lantrix
Last active August 29, 2015 14:06
Show Gist options
  • Save lantrix/b3916a3a91ff95e887d4 to your computer and use it in GitHub Desktop.
Save lantrix/b3916a3a91ff95e887d4 to your computer and use it in GitHub Desktop.
robocopy in powershell
#Path of git:master repo synced onto web console
$sqlSourcePath = "C:\Source Folder" #with trailing backslash
$sqlDestinationDrive = "C" #raw drive letter only
$sqlDestinationPath = "SQL_commands" # without trailing backslash or drive e.g.: path\to\copy\folder
$RobocopySyntax = ' /COPY:DAT /R:0 /W:0 /MIR'
$a = [char]34
$Source = $sqlSourcePath
$Destination = '\\' + $destinationIP + '\' + $sqlDestinationDrive + '$' + '\' + $sqlDestinationPath + '\'
$Robocopy = 'robocopy ' + $a + $Source + $a + ' ' + $a + $Destination + $a + $RobocopySyntax
invoke-expression $Robocopy
$Robocopy
Get-Process robocopy | Foreach-Object { $_.WaitForExit() }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment