Created
September 2, 2016 23:50
-
-
Save FooBartn/af4e14db6c7701e623263b1a7a41782b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Invoke-Robocopy () { | |
[cmdletbinding()] | |
param ( | |
# Copy from location | |
[Parameter(Mandatory=$true)] | |
[string] | |
$Path, | |
# Copy to location | |
[Parameter(Mandatory=$true)] | |
$Destination, | |
# List of arguments to be splatted to ROBOCOPY | |
[Parameter(Mandatory=$true)] | |
[array] | |
$ArgumentList | |
) | |
ROBOCOPY.exe $Path $Destination @ArgumentList | |
switch ($LastExitCode) { | |
0 { Write-Verbose 'No files copied. Source and destination are in sync' } | |
1 { Write-Verbose 'Files were copied successfully'} | |
2 { Write-Verbose 'Extra files/directories detected. Housekeeping may be required.'} | |
4 { Write-Verbose 'Mismatched files/directories detected. Housekeeping may be required.'} | |
8 { Write-Error 'Some files/directories could not be copied'} | |
10 { Write-Error 'Usage error or an error due to insufficient access privileges'} | |
} | |
exit ($LastExitCode -band 24) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment