2
Set-ExecutionPolicy -ExecutionPolicy Bypass
$webServers = "remoteservername1"

$deploymentCredentials = Get-Credential


Invoke-Command -ComputerName $webServers -Credential $deploymentCredentials -ScriptBlock {


$appVersionDirectory = "C:\Test"

The New-Item creates the directory without a problem:

New-Item -ItemType directory -Path $appVersionDirectory

The Copy-Item does not error, but will not copy any files

If I run this same Copy-Item command directly on the remote server, it works!

$sourceFiles = "\\sourceserver\DeploymentSource\shared\*"
Copy-Item  $sourceFiles -Destination $appVersionDirectory

}

KJK
  • 41
  • 6
  • Here's [an article on the two-hop problem](https://blogs.technet.microsoft.com/heyscriptingguy/2013/04/04/enabling-multihop-remoting/) that you are likely running into. Note that CredSSP has some security risks to it. It's probably just better to "push" the files to the server prior to Invoke-Command. – BenH Sep 15 '16 at 13:22
  • Thank you! I ended up using "Resource-Based Kerberos Constrained Delegation" described in this article that I found from the link you provided. https://blogs.technet.microsoft.com/ashleymcglone/2016/08/30/powershell-remoting-kerberos-double-hop-solved-securely/ – KJK Sep 15 '16 at 14:16
  • Correction. I ended up pushing the files prior to the Invoke-Command. The "Resource-Based Kerberos Constrained Delegation" approach was still giving me fits and only working part of the time. Thanks again for your response to my question today. – KJK Sep 15 '16 at 18:59

0 Answers0