Am using Powershell script to copy a folder from local system to remote VM.
The below script works fine when am running from my local system.
New-SelfSignedCertificate -DnsName dummy.southcentralus.cloudapp.azure.com -CertStoreLocation Cert:\LocalMachine\My
winrm create winrm/config/Listener?Address=*+Transport=HTTPS @{Hostname="dummy.southcentralus.cloudapp.azure.com"; CertificateThumbprint="9C207E7D249D385FDE9D4BBFE7AF7EB008RDGD"}
$pw = convertto-securestring -AsPlainText -Force -String <Password>
$cred = new-object -typename System.Management.Automation.PSCredential - argumentlist <username>,$pw
$session = new-pssession -computername dummy.southcentralus.cloudapp.azure.com -credential $cred
Copy-Item -Path C:\Jenkins\workspace\deploy-service\bin.zip -Destination F:\destpath\bin1.zip -ToSession $session
But when I use the same script in Jenkins at the build step. It throws me an error as given below.
"WinRM cannot process the request. The following error with errorcode 0x8009030d occurred while using Negotiate authentication: A specified logon session does not exist. It may already have been terminated."
What I tried So Far to resolve this error:
Change in this line, fixed my issue.
$cred = new-object -typename System.Management.Automation.PSCredential - argumentlist <username>,$pw
as
$cred = new-object -typename System.Management.Automation.PSCredential - argumentlist <domainname>\<username>,$pw
PSCredential, would expect the credential to be with domainname\username rather than passing username alone.
User contributions licensed under CC BY-SA 3.0