Skip to content

Instantly share code, notes, and snippets.

@rferreiraperez
Created November 14, 2023 09:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rferreiraperez/48f4ffd4c3379a578030d9f5f52d084a to your computer and use it in GitHub Desktop.
Save rferreiraperez/48f4ffd4c3379a578030d9f5f52d084a to your computer and use it in GitHub Desktop.
Copying data over the network in Windows
param(
[string]$Source,
[string]$Destination,
[string]$Log,
[string]$Username,
[string]$Password
)
# Establish network connection
net use $Destination /user:$Username $Password
# Run Robocopy
robocopy $Source $Destination /E /V /R:1 /W:1 /TEE /LOG:$Log
# Disconnect network connection
net use $Destination /d
@rferreiraperez
Copy link
Author

rferreiraperez commented Nov 14, 2023

When running the script, provide the values for the parameters:

.\windows-copy-data-over-the-network.ps1 -Source "\\datastore\source\data" -Destination "\\datastore\target\data" -Log "C:\output.log" -Username "usr" -Password "pwd"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment