Created
March 15, 2019 15:18
-
-
Save junecastillote/b9b776315bf69081c5650f31175b2bc7 to your computer and use it in GitHub Desktop.
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
#REGION VARIABLES | |
#// username (domain\username) | |
$uname = "domain\user" | |
#password - plain text | |
$passwd = "p@ssw0rd" | |
#// remote computer where the files to be copied are hosted | |
$remoteSourceComputer = "server01" | |
#// source folder from the remote computer (DO NOT USE UNC PATH) | |
$remoteSourceFolder = "C:\SourceFolder" | |
#// destination folder on the local machine | |
$localDestinationFolder = "C:\DestinationFolder" | |
#ENDREGION | |
$secpasswd = ConvertTo-SecureString "$passwd" -AsPlainText -Force | |
$credential = New-Object System.Management.Automation.PSCredential ($uname, $secpasswd) | |
$Session = New-PSSession -ComputerName $remoteSourceComputer -Credential $credential | |
Copy-Item -Path $remoteSourceFolder\*.* -FromSession $Session -Destination $localDestinationFolder -Confirm:$false -Force |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment