-1

I am using below command from my test01 server from where i want to invoke the copy-item command on the test02 server.. I am facing access is denied issue.

test01 is the servername where my sharefolder is there test02 is the remote machine

$password = ConvertTo-SecureString “pass” -AsPlainText -Force $Cred = New-Object System.Management.Automation.PSCredential (“work”, $password) Invoke-Command -ScriptBlock {Copy-Item '\test01\new' 'c:\test' -Force -Recurse} -ComputerName "test02" -Credential $Cred strong text

chipri
  • 29
  • 5
  • Not get your latest information,if the answer is helpful, please [mark it as answer](https://meta.stackexchange.com/a/5235/515442), just click the option like this . Or if you have any concern, feel free to share it here. – LoLance Jun 18 '20 at 07:01

1 Answers1

0

It seems that your build agent lacks Admin permission to perform the action. (Invoke-Command -ComputerName requires admin permission...)

Try updating current agent or installing a new agent(suggest creating a new agent pool) with Admin account and then start the agent with Admin account. You can refer to this ticket for more details.

LoLance
  • 25,666
  • 1
  • 39
  • 73