Teamcity pipeline build not taking powershell env's

Hi,

 

I'm trying to run a powershell script from a pipeline that run's the invoke-command 

 

$Credential = [PSCredential]::new('Administrator', (ConvertTo-SecureString $ServerPassword -AsPlainText -Force))

Get-ChildItem WSMan:\localhost\client | Out-String | Write-Host
Get-ChildItem WSMan:\localhost\client\Auth | Out-String | Write-Host

Invoke-Command -ComputerName $ServerIP -Credential $Credential -Authentication Basic -ScriptBlock {

 

i'm getting the following error from the teamcity pipeline

 

[22:47:48][Step 1/18] [172.31.26.4] Connecting to remote server 172.31.26.4 failed with the
[22:47:48][Step 1/18] following error message : The WinRM client cannot process the request.
[22:47:48][Step 1/18] Unencrypted traffic is currently disabled in the client configuration. Change
[22:47:48][Step 1/18] the client configuration and try the request again. For more information, see
[22:47:48][Step 1/18] the about_Remote_Troubleshooting Help topic.
[22:47:48][Step 1/18] + CategoryInfo : OpenError: (172.31.26.4:String) [], PSRemotingTr
[22:47:48][Step 1/18] ansportException
[22:47:48][Step 1/18] + FullyQualifiedErrorId : -2144108322,PSSessionStateBroken
 
 
I have added
Get-ChildItem WSMan:\localhost\client | Out-String | Write-Host
Get-ChildItem WSMan:\localhost\client\Auth | Out-String | Write-Host
 
which is showing the following
14:01:37] [Step 1/18] WSManConfig: Microsoft.WSMan.Management\WSMan::localhost\Client
[14:01:37] [Step 1/18]
[14:01:37] [Step 1/18] Type Name SourceOfValue Value
[14:01:37] [Step 1/18] ---- ---- ------------- -----
[14:01:37] [Step 1/18] System.String NetworkDelayms 5000
[14:01:37] [Step 1/18] System.String URLPrefix wsman
[14:01:37] [Step 1/18] System.String AllowUnencrypted false
[14:01:37] [Step 1/18] Container Auth
[14:01:37] [Step 1/18] Container DefaultPorts
[14:01:37] [Step 1/18] System.String TrustedHosts *
[14:01:37] [Step 1/18]
[14:01:37] [Step 1/18]
[14:01:37] [Step 1/18]
[14:01:37] [Step 1/18]
[14:01:37] [Step 1/18]
[14:01:37] [Step 1/18] WSManConfig: Microsoft.WSMan.Management\WSMan::localhost\Client\Auth
[14:01:37] [Step 1/18]
[14:01:37] [Step 1/18] Type Name SourceOfValue Value
[14:01:37] [Step 1/18] ---- ---- ------------- -----
[14:01:37] [Step 1/18] System.String Basic true
[14:01:37] [Step 1/18] System.String Digest true
[14:01:37] [Step 1/18] System.String Kerberos true
[14:01:37] [Step 1/18] System.String Negotiate true
[14:01:37] [Step 1/18] System.String Certificate true
[14:01:37] [Step 1/18] System.String CredSSP false
 
as you can see it is saying it's false as in not enabled, when i run the same command from the teamcirty server in powershell I get the following
WSManConfig: Microsoft.WSMan.Management\WSMan::localhost\Service
Type Name SourceOfValue Value
---- ---- ------------- -----
System.String RootSDDL O:NSG:BAD:P(A;;GA;;;BA)(A
System.String MaxConcurrentOperations 4294967295
System.String MaxConcurrentOperationsPerUser 1500
System.String EnumerationTimeoutms 240000
System.String MaxConnections 300
System.String MaxPacketRetrievalTimeSeconds 120
System.String AllowUnencrypted true
Container Auth
Container DefaultPorts
System.String IPv4Filter *
System.String IPv6Filter *
System.String EnableCompatibilityHttpListen… false
System.String EnableCompatibilityHttpsListe… false
System.String CertificateThumbprint
System.String AllowRemoteAccess true
 
which is saying it's enabled
 
I tried restarting the service, I tried restarting the server but still get the same issue. 
 
Teamcity server is windows 2016 and the client server is windows 2012 R2
not on a domain or anything 
 
running
TeamCity Professional 2018.2.1 (build 61078)
 
 
0
2 comments

Hi,

 

builds don't run on the teamcity server, but on a teamcity agent. You need to make sure that the AllowUnencrypted is enabled for the powershell installation being used by the build agent. Also, I'm not particularly familiar with how this settings are created, but also keep in mind that they will be ran by the user running the build agent's process, so if settings might differ based on user, you would want to ensure the user has it as well.

If it still doesn't work properly, please follow the steps here, including those which explicitly mention how to report the issue: https://www.jetbrains.com/help/teamcity/common-problems.html#CommonProblems-BuildworkslocallybutfailsormisbehavesinTeamCity

0
Avatar
Permanently deleted user

it turned out to be the Agent was running as system account, I changed it to Administrator and this worked, or I could have added the system account into the system administrator group

0

Please sign in to leave a comment.