mirror of
https://github.com/fleschutz/PowerShell.git
synced 2024-11-08 00:54:04 +01:00
Add sync-folder.ps1
This commit is contained in:
parent
d3e1550e02
commit
b455a05458
31
scripts/sync-folder.ps1
Normal file
31
scripts/sync-folder.ps1
Normal file
@ -0,0 +1,31 @@
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Sync's two folders
|
||||
.DESCRIPTION
|
||||
This PowerShell script synchronizes two folders via Robocopy (useful for e.g. backups).
|
||||
NOTE: Make sure the target folder is correct because the content gets replaced!
|
||||
.PARAMETER Source
|
||||
Path to the source folder
|
||||
.PARAMETER Destination
|
||||
Path to the destination folder
|
||||
.EXAMPLE
|
||||
sync-folder -source C:\Folder01 -destination C:\Folder02
|
||||
#>
|
||||
|
||||
function Sync-Folder
|
||||
{
|
||||
|
||||
[CmdletBinding()]
|
||||
param (
|
||||
|
||||
[Parameter(Mandatory)][string]$Source,
|
||||
[Parameter(Mandatory)][string]$Destination
|
||||
)
|
||||
|
||||
$RobocopyParams = $Source, $Destination, '/MIR', '/FFT', '/NDL', '/NP', '/NS'
|
||||
|
||||
robocopy.exe $RobocopyParams
|
||||
|
||||
if ($LastExitCode -gt 3) { throw 'Robocopy failed.' }
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user