My goal is to execute the PowerShell file on remote server through TFS tasks 'PowerShell on Target Machines
'
for that Steps I have taken so far are:
Both Build and remote server already enabled
Enable-PSRemoting -Force
also added the trusthost server IPs added
Set-Item wsman:\localhost\client\trustedhosts *
and
Restart-Service WinRM
after doing all above steps still got the following error on TFS task
##[error]Connecting to remote server 'REMOTE SERVER IP' failed with the following error message The client cannot connect to the destination specified in the request. Verify that the service on the destination is running and is accepting requests. Consult the logs and documentation for the WS-Management service running on the destination, most commonly IIS or WinRM. If the destination is the WinRM service, run the following command on the destination to analyze and configure the WinRM service: "winrm quickconfig". For more information, see the about_Remote_Troubleshooting Help topic.
What will be the reason or what I am missing any thing.
Here are some possible causes for the error and some troubleshooting advices:
Advice 1
This problem may occur if the Window Remote Management service and its listener functionality are broken.
To resolve this problem, follow these steps:
Step1. Install the latest Windows Remote Management update.
Step2. Run the following command to restore the listener configuration:
Step3. Run the following command to perform a default configuration of the Windows Remote Management service and its listener:
Click this document for detailed information.
Advice 2
The group policy configuration of fire wall exception may be incorrect. A configuration error in the policy results in an empty value for the
ListeningOn
property. Use the following command to check the value.Click this document for detailed information and how to solve the issue.
Adivce 3
The possible cause of the question is the error settings of HTTP proxy. Because PowerShell remoting uses the HTTP protocol, it is affected by HTTP proxy settings.
To resolve this problem:
Step1. Use the
ProxyAccessType
,ProxyAuthentication
, andProxyCredential
parameters of theNew-PSSessionOption
cmdlet to create a session option object with the proxy settings for your enterprise. Save the option object is a variable.Step2. Use the variable that contains the option object as the value of the
SessionOption
parameter of aNew-PSSession
,Enter-PSSession
, orInvoke-Command
command.Click this document for detailed information.
Advice 4
Try running your PowerShell file locally and see if it has the same error.