Created
March 6, 2015 01:48
-
-
Save bradymholt/77989d60cc212b01752c to your computer and use it in GitHub Desktop.
Copies a directory remotely, from the context of the remote machine to prevent bumerang style copy
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
param ($computerName, $username, $password, $sourceDirectory, $targetDirectory) | |
$securePassword = ConvertTo-SecureString $password -AsPlainText -Force | |
$credentials = New-Object System.Management.Automation.PsCredential($username, $securePassword) | |
Invoke-Command -ComputerName $computerName -Credential $credentials -ScriptBlock { Copy-Item $args[0] $args[1] -recurse } -ArgumentList $sourceDirectory,$targetDirectory |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment