Created
November 14, 2023 09:41
-
-
Save rferreiraperez/48f4ffd4c3379a578030d9f5f52d084a to your computer and use it in GitHub Desktop.
Copying data over the network in Windows
This file contains 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
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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"