5

I have configure the winrm.

I am getting below response after running winrm quickconfig as the winrm service is already running.

WinRM service is already running on this machine.

WinRM is already set up for remote management on this computer.

Also, If I Do New-PSSession -ComputerName DESKTOP-0DNHIDE

I am getting below output

 Id Name            ComputerName    ComputerType    State         ConfigurationName     Availability
 -- ----            ------------    ------------    -----         -----------------     ------------
  5 WinRM5          DESKTOP-0DNHIDE RemoteMachine   Opened        Microsoft.PowerShell     Available

I am also able to establish PSConnection using

`Enter-PSSession -Computername DESKTOP-0DNHIDE`

But Still when I try to deploy CSharp application using Azure Devops Pipeline getting below error

[error]Microsoft.PowerShell.Commands.WriteErrorException: Deployment on one or more machines failed. System.Management.Automation.Remoting.PSRemotingTransportException: Connecting to remote server xx.xx.xx.xx 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.

I am using WinRM - IIS Web App Deployment task in azure devops pipeline for deploying CSharp application on local IIS Server.

AzureDevops agent is configured for my local machine.

Complete log from Release pipeline is below:

2019-07-19T02:58:20.7948043Z ##[debug]Evaluating condition for step: 'Manage IISWebsite'
2019-07-19T02:58:20.7950382Z ##[debug]Evaluating: succeeded()
2019-07-19T02:58:20.7950615Z ##[debug]Evaluating succeeded:
2019-07-19T02:58:20.7951602Z ##[debug]=> True
2019-07-19T02:58:20.7952146Z ##[debug]Result: True
2019-07-19T02:58:20.7952671Z ##[section]Starting: Manage IISWebsite
2019-07-19T02:58:20.8496506Z ==============================================================================
2019-07-19T02:58:20.8496698Z Task         : WinRM - IIS Web App Management
2019-07-19T02:58:20.8496768Z Description  : Connect via WinRM, to create or update a Website, Web App, Virtual Directories, and Application Pool locally on IIS
2019-07-19T02:58:20.8496827Z Version      : 2.1.0
2019-07-19T02:58:20.8496861Z Author       : Microsoft Corporation
2019-07-19T02:58:20.8496895Z Help         : [More Information](http://aka.ms/IISMgmt)
2019-07-19T02:58:20.8496934Z ==============================================================================
2019-07-19T02:58:20.8798461Z Preparing task execution handler.
2019-07-19T02:58:21.7605314Z Executing the powershell script: E:\NewAgent\_work\_tasks\IISWebAppMgmt_0f5cd14f-3c01-4d5c-8f7a-eb96c5738dcc\2.1.0\Main.ps1
2019-07-19T02:58:21.7606356Z ##[debug]PowerShellHandler.Execute - AddCommand(E:\NewAgent\_work\_tasks\IISWebAppMgmt_0f5cd14f-3c01-4d5c-8f7a-eb96c5738dcc\2.1.0\Main.ps1)
2019-07-19T02:58:21.7606607Z ##[debug]PowerShellHandler.Execute - Add inputParameters
2019-07-19T02:58:21.7606785Z ##[debug]PowerShellHandler.Execute - AddParameter(machinesList=localhost)
2019-07-19T02:58:21.7606939Z ##[debug]PowerShellHandler.Execute - AddParameter(AdminUserName=desktop-0dnhide\hp)
2019-07-19T02:58:21.7607111Z ##[debug]PowerShellHandler.Execute - AddParameter(AdminPassword=*******)
2019-07-19T02:58:21.7607282Z ##[debug]PowerShellHandler.Execute - AddParameter(WinRMProtocol=Https)
2019-07-19T02:58:21.7607481Z ##[debug]PowerShellHandler.Execute - AddParameter(TestCertificate=true)
2019-07-19T02:58:21.7607679Z ##[debug]PowerShellHandler.Execute - AddParameter(IISDeploymentType=IISWebsite)
2019-07-19T02:58:21.7607883Z ##[debug]PowerShellHandler.Execute - AddParameter(ActionIISWebsite=CreateOrUpdateWebsite)
2019-07-19T02:58:21.7607995Z ##[debug]PowerShellHandler.Execute - AddParameter(ActionIISApplicationPool=CreateOrUpdateAppPool)
2019-07-19T02:58:21.7608086Z ##[debug]PowerShellHandler.Execute - AddParameter(StartStopWebsiteName=)
2019-07-19T02:58:21.7608180Z ##[debug]PowerShellHandler.Execute - AddParameter(WebsiteName=POC)
2019-07-19T02:58:21.7608260Z ##[debug]PowerShellHandler.Execute - AddParameter(WebsitePhysicalPath=D:\PublishApplication\POC\)
2019-07-19T02:58:21.7608349Z ##[debug]PowerShellHandler.Execute - AddParameter(WebsitePhysicalPathAuth=WebsiteUserPassThrough)
2019-07-19T02:58:21.7608429Z ##[debug]PowerShellHandler.Execute - AddParameter(WebsiteAuthUserName=)
2019-07-19T02:58:21.7608517Z ##[debug]PowerShellHandler.Execute - AddParameter(WebsiteAuthUserPassword=)
2019-07-19T02:58:21.7608597Z ##[debug]PowerShellHandler.Execute - AddParameter(AddBinding=true)
2019-07-19T02:58:21.7608699Z ##[debug]PowerShellHandler.Execute - AddParameter(CreateOrUpdateAppPoolForWebsite=true)
2019-07-19T02:58:21.7608783Z ##[debug]PowerShellHandler.Execute - AddParameter(ConfigureAuthenticationForWebsite=false)
2019-07-19T02:58:21.7608870Z ##[debug]PowerShellHandler.Execute - AddParameter(Protocol=http)
2019-07-19T02:58:21.7609293Z ##[debug]PowerShellHandler.Execute - AddParameter(IPAddress=All Unassigned)
2019-07-19T02:58:21.7609385Z ##[debug]PowerShellHandler.Execute - AddParameter(Port=8086)
2019-07-19T02:58:21.7609468Z ##[debug]PowerShellHandler.Execute - AddParameter(ServerNameIndication=false)
2019-07-19T02:58:21.7609548Z ##[debug]PowerShellHandler.Execute - AddParameter(HostNameWithOutSNI=)
2019-07-19T02:58:21.7609638Z ##[debug]PowerShellHandler.Execute - AddParameter(HostNameWithHttp=)
2019-07-19T02:58:21.7609718Z ##[debug]PowerShellHandler.Execute - AddParameter(HostNameWithSNI=)
2019-07-19T02:58:21.7611169Z ##[debug]PowerShellHandler.Execute - AddParameter(SSLCertThumbPrint=)
2019-07-19T02:58:21.7611253Z ##[debug]PowerShellHandler.Execute - AddParameter(AppPoolNameForWebsite=POC-Pool)
2019-07-19T02:58:21.7611341Z ##[debug]PowerShellHandler.Execute - AddParameter(DotNetVersionForWebsite=v4.0)
2019-07-19T02:58:21.7611423Z ##[debug]PowerShellHandler.Execute - AddParameter(PipeLineModeForWebsite=Integrated)
2019-07-19T02:58:21.7611526Z ##[debug]PowerShellHandler.Execute - AddParameter(AppPoolIdentityForWebsite=ApplicationPoolIdentity)
2019-07-19T02:58:21.7611607Z ##[debug]PowerShellHandler.Execute - AddParameter(AppPoolUsernameForWebsite=)
2019-07-19T02:58:21.7611686Z ##[debug]PowerShellHandler.Execute - AddParameter(AppPoolPasswordForWebsite=)
2019-07-19T02:58:21.7611774Z ##[debug]PowerShellHandler.Execute - AddParameter(AnonymousAuthenticationForWebsite=false)
2019-07-19T02:58:21.7611852Z ##[debug]PowerShellHandler.Execute - AddParameter(BasicAuthenticationForWebsite=false)
2019-07-19T02:58:21.7611951Z ##[debug]PowerShellHandler.Execute - AddParameter(WindowsAuthenticationForWebsite=true)
2019-07-19T02:58:21.7612029Z ##[debug]PowerShellHandler.Execute - AddParameter(ParentWebsiteNameForVD=)
2019-07-19T02:58:21.7612117Z ##[debug]PowerShellHandler.Execute - AddParameter(VirtualPathForVD=)
2019-07-19T02:58:21.7612198Z ##[debug]PowerShellHandler.Execute - AddParameter(PhysicalPathForVD=%SystemDrive%\inetpub\wwwroot)
2019-07-19T02:58:21.7612293Z ##[debug]PowerShellHandler.Execute - AddParameter(VDPhysicalPathAuth=VDUserPassThrough)
2019-07-19T02:58:21.7612372Z ##[debug]PowerShellHandler.Execute - AddParameter(VDAuthUserName=)
2019-07-19T02:58:21.7612456Z ##[debug]PowerShellHandler.Execute - AddParameter(VDAuthUserPassword=)
2019-07-19T02:58:21.7612535Z ##[debug]PowerShellHandler.Execute - AddParameter(ParentWebsiteNameForApplication=)
2019-07-19T02:58:21.7612618Z ##[debug]PowerShellHandler.Execute - AddParameter(VirtualPathForApplication=)
2019-07-19T02:58:21.7612700Z ##[debug]PowerShellHandler.Execute - AddParameter(PhysicalPathForApplication=%SystemDrive%\inetpub\wwwroot)
2019-07-19T02:58:21.7612789Z ##[debug]PowerShellHandler.Execute - AddParameter(ApplicationPhysicalPathAuth=ApplicationUserPassThrough)
2019-07-19T02:58:21.7612875Z ##[debug]PowerShellHandler.Execute - AddParameter(ApplicationAuthUserName=)
2019-07-19T02:58:21.7612953Z ##[debug]PowerShellHandler.Execute - AddParameter(ApplicationAuthUserPassword=)
2019-07-19T02:58:21.7613048Z ##[debug]PowerShellHandler.Execute - AddParameter(CreateOrUpdateAppPoolForApplication=false)
2019-07-19T02:58:21.7613128Z ##[debug]PowerShellHandler.Execute - AddParameter(AppPoolNameForApplication=)
2019-07-19T02:58:21.7613214Z ##[debug]PowerShellHandler.Execute - AddParameter(DotNetVersionForApplication=v4.0)
2019-07-19T02:58:21.7613292Z ##[debug]PowerShellHandler.Execute - AddParameter(PipeLineModeForApplication=Integrated)
2019-07-19T02:58:21.7613447Z ##[debug]PowerShellHandler.Execute - AddParameter(AppPoolIdentityForApplication=ApplicationPoolIdentity)
2019-07-19T02:58:21.7613540Z ##[debug]PowerShellHandler.Execute - AddParameter(AppPoolUsernameForApplication=)
2019-07-19T02:58:21.7613628Z ##[debug]PowerShellHandler.Execute - AddParameter(AppPoolPasswordForApplication=)
2019-07-19T02:58:21.7613707Z ##[debug]PowerShellHandler.Execute - AddParameter(AppPoolName=)
2019-07-19T02:58:21.7613795Z ##[debug]PowerShellHandler.Execute - AddParameter(DotNetVersion=v4.0)
2019-07-19T02:58:21.7614062Z ##[debug]PowerShellHandler.Execute - AddParameter(PipeLineMode=Integrated)
2019-07-19T02:58:21.7614152Z ##[debug]PowerShellHandler.Execute - AddParameter(AppPoolIdentity=ApplicationPoolIdentity)
2019-07-19T02:58:21.7614233Z ##[debug]PowerShellHandler.Execute - AddParameter(AppPoolUsername=)
2019-07-19T02:58:21.7614312Z ##[debug]PowerShellHandler.Execute - AddParameter(AppPoolPassword=)
2019-07-19T02:58:21.7614398Z ##[debug]PowerShellHandler.Execute - AddParameter(StartStopRecycleAppPoolName=)
2019-07-19T02:58:21.7614476Z ##[debug]PowerShellHandler.Execute - AddParameter(AppCmdCommands=)
2019-07-19T02:58:21.7615059Z ##[debug]PowerShellHandler.Execute - AddParameter(DeployInParallel=true)
2019-07-19T02:58:22.4170890Z ##[debug]PowerShellHandler.Execute - Invoke
2019-07-19T02:58:22.4171297Z ##[debug]Resetting input encoding.
2019-07-19T02:58:22.4172420Z ##[debug]Loading module from path 'E:\NewAgent\_work\_tasks\IISWebAppMgmt_0f5cd14f-3c01-4d5c-8f7a-eb96c5738dcc\2.1.0\VstsTaskSdk\VstsTaskSdk.psd1'.
2019-07-19T02:58:22.4172731Z ##[debug]Loading module from path 'E:\NewAgent\_work\_tasks\IISWebAppMgmt_0f5cd14f-3c01-4d5c-8f7a-eb96c5738dcc\2.1.0\VstsTaskSdk\VstsTaskSdk.psm1'.
2019-07-19T02:58:22.4280894Z ##[warning]VstsTaskSdk is designed for use with powershell.exe (ConsoleHost). Output may be different when used with other hosts.
2019-07-19T02:58:22.4293211Z ##[debug]Processed: ##vso[task.logissue type=warning]VstsTaskSdk is designed for use with powershell.exe (ConsoleHost). Output may be different when used with other hosts.
2019-07-19T02:58:22.4293844Z ##[debug]NonInteractive: False
2019-07-19T02:58:22.4294206Z ##[debug]Adding long path native methods.
2019-07-19T02:58:22.8215634Z ##[debug]Exporting function 'Find-Files'.
2019-07-19T02:58:22.8217695Z ##[debug]Exporting function 'Get-Endpoint'.
2019-07-19T02:58:22.8218463Z ##[debug]Exporting function 'Get-Input'.
2019-07-19T02:58:22.8218837Z ##[debug]Exporting function 'Get-TaskVariable'.
2019-07-19T02:58:22.8219129Z ##[debug]Exporting function 'Get-TaskVariableInfo'.
2019-07-19T02:58:22.8219320Z ##[debug]Exporting function 'Set-TaskVariable'.
2019-07-19T02:58:22.8219534Z ##[debug]Exporting function 'Get-LocString'.
2019-07-19T02:58:22.8219775Z ##[debug]Exporting function 'Import-LocStrings'.
2019-07-19T02:58:22.8219971Z ##[debug]Exporting function 'Write-AddAttachment'.
2019-07-19T02:58:22.8220186Z ##[debug]Exporting function 'Write-AddBuildTag'.
2019-07-19T02:58:22.8220384Z ##[debug]Exporting function 'Write-AssociateArtifact'.
2019-07-19T02:58:22.8240821Z ##[debug]Adding exceptions types.
2019-07-19T02:58:23.4242116Z ##[debug]Loading resource strings from: E:\NewAgent\_work\_tasks\IISWebAppMgmt_0f5cd14f-3c01-4d5c-8f7a-eb96c5738dcc\2.1.0\VstsTaskSdk\lib.json
2019-07-19T02:58:23.4258236Z 
2019-07-19T02:58:23.4259926Z 
2019-07-19T02:58:23.5622842Z ##[debug]Loaded 15 strings.
2019-07-19T02:58:23.5623707Z 
2019-07-19T02:58:23.5624183Z 
2019-07-19T02:58:23.6790360Z ##[debug]SYSTEM_CULTURE: 'en-US'
2019-07-19T02:58:23.6790598Z 
2019-07-19T02:58:23.6790668Z 
2019-07-19T02:58:23.6911976Z ##[debug]Importing the module 'Microsoft.PowerShell.Security'.
2019-07-19T02:58:23.6912832Z 
2019-07-19T02:58:23.6913316Z 
2019-07-19T02:58:23.7350193Z ##[warning]The 'Microsoft.PowerShell.Security' module was not imported because the 'Microsoft.PowerShell.Security' snap-in was already imported.
2019-07-19T02:58:23.7350721Z ##[debug]Processed: ##vso[task.logissue type=warning]The 'Microsoft.PowerShell.Security' module was not imported because the 'Microsoft.PowerShell.Security' snap-in was already imported.
2019-07-19T02:58:23.7351597Z 
2019-07-19T02:58:23.7467957Z ##[debug]Loading module from path 'E:\NewAgent\_work\_tasks\IISWebAppMgmt_0f5cd14f-3c01-4d5c-8f7a-eb96c5738dcc\2.1.0\RemoteDeployer\RemoteDeployer.psd1'.
2019-07-19T02:58:23.7524741Z ##[debug]Loading module from path 'E:\NewAgent\_work\_tasks\IISWebAppMgmt_0f5cd14f-3c01-4d5c-8f7a-eb96c5738dcc\2.1.0\RemoteDeployer\RemoteDeployer.psm1'.
2019-07-19T02:58:23.8882064Z ##[debug]Loading resource strings from: E:\NewAgent\_work\_tasks\IISWebAppMgmt_0f5cd14f-3c01-4d5c-8f7a-eb96c5738dcc\2.1.0\RemoteDeployer\module.json
2019-07-19T02:58:23.9162207Z ##[debug]Loaded 10 strings.
2019-07-19T02:58:23.9176743Z ##[debug]SYSTEM_CULTURE: 'en-US'
2019-07-19T02:58:23.9182612Z ##[debug]Loading resource strings from: E:\NewAgent\_work\_tasks\IISWebAppMgmt_0f5cd14f-3c01-4d5c-8f7a-eb96c5738dcc\2.1.0\RemoteDeployer\Strings\resources.resjson\en-US\resources.resjson
2019-07-19T02:58:23.9487322Z ##[debug]Loaded 10 strings.
2019-07-19T02:58:23.9488965Z ##[debug]Exporting function 'Invoke-RemoteScript'.
2019-07-19T02:58:23.9493029Z ##[debug]Importing function 'Invoke-RemoteScript'.
2019-07-19T02:58:23.9494414Z ##[debug]Entering script Utility.ps1
2019-07-19T02:58:23.9722712Z ##[debug]Triming inputs for excess spaces, double quotes
2019-07-19T02:58:24.0255308Z ##[debug]Initiating action 'create or update' website with user specified application pool.
2019-07-19T02:58:24.0261470Z ##[debug]Triming inputs for excess spaces, double quotes
2019-07-19T02:58:24.0282354Z ##[debug]Initiating action 'create or update' website with user specified application pool.
2019-07-19T02:58:24.0873059Z ##[debug]Executing main funnction in AppCmdOnTargetMachines : Invoke-Main -ActionIISWebsite CreateOrUpdateWebsite -WebsiteName "POC" -PhysicalPath "D:\PublishApplication\POC" -PhysicalPathAuth "WebsiteUserPassThrough" -PhysicalPathAuthUsername "" -PhysicalPathAuthUserPassword "****" -AddBinding true -Bindings "{
2019-07-19T02:58:24.0873377Z     `"port`":  `"8086`",
2019-07-19T02:58:24.0873458Z     `"sniFlag`":  `"false`",
2019-07-19T02:58:24.0873504Z     `"ipAddress`":  `"All Unassigned`",
2019-07-19T02:58:24.0873546Z     `"hostname`":  `"`",
2019-07-19T02:58:24.0873599Z     `"sslThumbprint`":  {
2019-07-19T02:58:24.0873626Z 
2019-07-19T02:58:24.0873665Z                       },
2019-07-19T02:58:24.0873704Z     `"protocol`":  `"http`"
2019-07-19T02:58:24.0873767Z }" -ActionIISApplicationPool "CreateOrUpdateAppPool" -AppPoolName "POC-Pool" -DotNetVersion "v4.0" -PipeLineMode "Integrated" -AppPoolIdentity ApplicationPoolIdentity -AppPoolUsername "" -AppPoolPassword "****" -configureAuthentication false -anonymousAuthentication false -basicAuthentication false -windowsAuthentication true -AppCmdCommands ""
2019-07-19T02:58:24.0992859Z ##[debug]Executing Run-RemoteDeployment
2019-07-19T02:58:24.1034386Z ##[debug]Executing Parse-TargetMachineNames
2019-07-19T02:58:24.1207070Z ##[debug]TargetMachineName: 'localhost'
2019-07-19T02:58:24.1254366Z ##[debug]Finished executing Parse-TargetMachineNames
2019-07-19T02:58:24.1353961Z ##[debug]Executing Get-NewPSSessionOption
2019-07-19T02:58:24.1356759Z ##[debug]New-PSSessionOption command: New-PSSessionOption -SkipCACheck
2019-07-19T02:58:24.1516828Z ##[debug]Finished executing Get-NewPSSessionOption
2019-07-19T02:58:24.1541020Z ##[debug]Executing Get-TargetMachineCredential: desktop-0dnhide\hp
2019-07-19T02:58:24.1624955Z ##[debug]Finished executing Get-TargetMachineCredential
2019-07-19T02:58:24.1641826Z Starting remote execution of Invoke-Main script for "IISWebsite" with action "CreateOrUpdateWebsite"
2019-07-19T02:58:24.1642167Z 
2019-07-19T02:58:24.1642368Z 
2019-07-19T02:58:24.2356493Z ##[debug]Entering Invoke-RemoteScript.
2019-07-19T02:58:24.2664601Z ##[debug] targetMachineNames: 'localhost'
2019-07-19T02:58:24.3174718Z ##[debug]Entering Get-TargetMachines.
2019-07-19T02:58:24.3250448Z ##[debug]Target Machines: localhost
2019-07-19T02:58:24.3470370Z ##[debug]ComputerName = localhost
2019-07-19T02:58:24.3502024Z ##[debug]WSManPort = 5986
2019-07-19T02:58:24.3508885Z ##[debug]Authentication = Default
2019-07-19T02:58:24.3509997Z ##[debug]SessionConfigurationName = microsoft.powershell
2019-07-19T02:58:24.3511134Z ##[debug]UseSSL = True
2019-07-19T02:58:24.3511754Z ##[debug]Total target machines are: 1
2019-07-19T02:58:24.3512392Z ##[debug]Leaving Get-TargetMachines.
2019-07-19T02:58:24.3955409Z ##[debug]Entering Get-WinRmConnectionToTargetMachine.
2019-07-19T02:58:24.3956756Z ##[debug] computerName: 'localhost'
2019-07-19T02:58:24.3958325Z ##[debug] port: '5986'
2019-07-19T02:58:24.3988051Z ##[debug] credential: 'System.Management.Automation.PSCredential'
2019-07-19T02:58:24.3989226Z ##[debug] authentication: 'Default'
2019-07-19T02:58:24.3991028Z ##[debug] sessionName: '25e787f9-5c81-4a00-97a0-778e363c1613'
2019-07-19T02:58:24.3992761Z ##[debug] sessionConfigurationName: 'microsoft.powershell'
2019-07-19T02:58:24.3994375Z ##[debug] useSsl: 'True'
2019-07-19T02:58:24.4127334Z ##[debug]Entering Get-NewPSSessionCommand.
2019-07-19T02:58:24.4128264Z ##[debug] computerName: 'localhost'
2019-07-19T02:58:24.4129785Z ##[debug] port: '5986'
2019-07-19T02:58:24.4131184Z ##[debug] authentication: 'Default'
2019-07-19T02:58:24.4132614Z ##[debug] sessionName: '25e787f9-5c81-4a00-97a0-778e363c1613'
2019-07-19T02:58:24.4133968Z ##[debug] useSsl: 'True'
2019-07-19T02:58:24.4135349Z ##[debug] sessionConfigurationName: 'microsoft.powershell'
2019-07-19T02:58:24.4136696Z ##[debug] NoCredential: 'False'
2019-07-19T02:58:24.4156316Z ##[debug]New-PSSessionCommand: New-PSSession -ComputerName 'localhost' -Port 5986 -Authentication Default -Name '25e787f9-5c81-4a00-97a0-778e363c1613' -Credential $credential -UseSSL -ErrorAction 'SilentlyContinue' -ErrorVariable sessionErrors -ConfigurationName 'microsoft.powershell'
2019-07-19T02:58:24.4159939Z ##[debug]Leaving Get-NewPSSessionCommand.
2019-07-19T02:58:24.4184417Z ##[debug]Trying to establish connection: Attempt #1
2019-07-19T02:58:26.5271873Z ##[debug]New-PSSession Error: Connecting to remote server localhost 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.
2019-07-19T02:58:56.5343753Z ##[debug]Trying to establish connection: Attempt #2
2019-07-19T02:58:58.5581592Z ##[debug]New-PSSession Error: Connecting to remote server localhost 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.
2019-07-19T02:59:28.5595487Z ##[debug]Trying to establish connection: Attempt #3
2019-07-19T02:59:30.5830533Z ##[debug]New-PSSession Error: Connecting to remote server localhost 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.
2019-07-19T03:00:00.6006127Z ##[error]Microsoft.PowerShell.Commands.WriteErrorException: Unable to create pssession. Error: 'Connecting to remote server localhost 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.'
2019-07-19T03:00:00.6012917Z ##[debug]Processed: ##vso[task.logissue type=error;]Microsoft.PowerShell.Commands.WriteErrorException: Unable to create pssession. Error: 'Connecting to remote server localhost 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.'
2019-07-19T03:00:00.6095909Z ##[debug]Leaving Get-WinRmConnectionToTargetMachine.
2019-07-19T03:00:00.6517300Z ##[debug]Entering Disconnect-WinRmConnectionToTargetMachines.
2019-07-19T03:00:00.6701326Z ##[debug]Entering Get-RemoteConnection.
2019-07-19T03:00:02.7813624Z ##[error]System.Management.Automation.RuntimeException: The remote session query failed for localhost 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".  ---> System.InvalidOperationException: <f:WSManFault xmlns:f="http://schemas.microsoft.com/wbem/wsman/1/wsmanfault" Code="2150858770" Machine="DESKTOP-0DNHIDE"><f: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". </f:Message></f:WSManFault>
2019-07-19T03:00:02.7815139Z ##[debug]Processed: ##vso[task.logissue type=error;]System.Management.Automation.RuntimeException: The remote session query failed for localhost 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".  ---> System.InvalidOperationException: <f:WSManFault xmlns:f="http://schemas.microsoft.com/wbem/wsman/1/wsmanfault" Code="2150858770" Machine="DESKTOP-0DNHIDE"><f: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". </f:Message></f:WSManFault>
2019-07-19T03:00:02.7818212Z    at System.Management.Automation.MshCommandRuntime.ThrowTerminatingError(ErrorRecord errorRecord)
2019-07-19T03:00:02.7818379Z    --- End of inner exception stack trace ---
2019-07-19T03:00:02.7952887Z ##[debug]Leaving Get-RemoteConnection.
2019-07-19T03:00:02.7963714Z ##[debug]Leaving Disconnect-WinRmConnectionToTargetMachines.
2019-07-19T03:00:02.7973434Z ##[debug]Leaving Invoke-RemoteScript.
2019-07-19T03:00:02.8081408Z ##[debug]Exception caught from task: System.Management.Automation.RuntimeException: PSSession could not be created for Machine:'localhost:5986'
2019-07-19T03:00:02.8090801Z ##[debug]Finished executing Run-RemoteDeployment
2019-07-19T03:00:02.8174981Z ##[error]Microsoft.PowerShell.Commands.WriteErrorException: Caught exception while executing main function: PSSession could not be created for Machine:'localhost:5986'
2019-07-19T03:00:02.8176209Z ##[debug]Processed: ##vso[task.logissue type=error;]Microsoft.PowerShell.Commands.WriteErrorException: Caught exception while executing main function: PSSession could not be created for Machine:'localhost:5986'
2019-07-19T03:00:02.8812346Z ##[error]PowerShell script completed with 3 errors.
2019-07-19T03:00:02.8825592Z ##[section]Finishing: Manage IISWebsite
Anand Deshmukh
  • 1,086
  • 2
  • 17
  • 35
  • 1
    The default WinRM relies on http/https i.e.,5985/5986 ports respectively. Have you been open these ports also? – Mengdi Liang Jul 18 '19 at 00:59
  • Yes, The Port 5985/5986 are enabled. I can see them using command `netstat -a -n` – Anand Deshmukh Jul 18 '19 at 04:30
  • Do you mind run `Enable-PSRemoting -Force` in your local and remote computer, and try the task again? – Mengdi Liang Jul 18 '19 at 10:33
  • @MerlinLiang-MSFT : yes, I already run `Enable-PSRemoting -force` & `winrm quickconfig`. The Target machine is my local windows10 machine. I have configure AzureDevops agent for local machine. Still I am getting same error – Anand Deshmukh Jul 19 '19 at 01:16
  • Did you check this CVE update: https://devblogs.microsoft.com/powershell/windows-security-change-affecting-powershell/ – Prasoon Karunan V Jul 22 '19 at 17:09

1 Answers1

0

You need to rebuild the WinRM on remote machine.

You should take backup of WinRm before you rebuild.

Corrupt WMI. Follow the steps below.

First Step to Try 1. Disable and stop the WMI service. a. sc config winmgmt start= disabled b. net stop winmgmt

  1. Run the following commands. a. Winmgmt /salvagerepository %windir%\System32\wbem b. Winmgmt /resetrepository %windir%\System32\wbem

  2. Re-enable the WMI service and then reboot the server to see how it goes. a. sc config winmgmt start= auto

If the problem remains, then try the following steps to rebuild the repository:

  1. Disable and stop the WMI service. a. sc config winmgmt start= disabled (note that there is a blank between '=' and 'disabled') b. net stop winmgmt

  2. Rename the repository folder (located at %windir%\System32\wbem\repository) to repository.old.

  3. Re-enable the WMI service. a. sc config winmgmt start= auto

  4. Reboot the server to see if the problem remains.

If the problem remains, then try the following steps Re-register all of the dlls and recompile the .mofs in the wbem folder and re-registering WMI Service and Provider. You can use the following script by saving to txt file then renaming to .bat and running from command prompt with admin right and changing focus to following directory: C:\Windows\System32\Wbem. @echo off sc config winmgmt start= disabled net stop winmgmt /y %systemdrive% cd %windir%\system32\wbem for /f %%s in ('dir /b *.dll') do regsvr32 /s % wmiprvse /regserver winmgmt /regserver sc config winmgmt start= auto net start winmgmt for /f %s in ('dir /s /b *.mof *.mfl') do mofcomp %s b. Reboot the machine and test WMI Warning: Rebuilding the WMI repository has resulted in some 3rd party products not working until their setup is re-run & their MOF re-added back to the repository.

If /salvagerepository or /resetrepository does not resolve the issue, then manually rebuild repository: 1. Change startup type to Window Management Instrumentation (WMI) Service to disabled 2. Stop the WMI Service; you may need to stop IP Helper Service first or other dependent services before it allows you to stop WMI Service 3. Rename the repository folder: C:\WINDOWS\system32\wbem\Repository to Repository.old 4. Open a CMD Prompt with elevated privileges 5. CD C:\windows\system32\wbem 6. for /f %s in ('dir /b /s *.dll') do regsvr32 /s %s 7. Set the WMI Service type back to Automatic and start WMI Service 8. cd /d c:\ ((go to the root of the c drive, this is important)) 9. for /f %s in ('dir /s /b *.mof *.mfl') do mofcomp %s 10. Reboot the server

Win2012 Possible Fix. Go to C:\WINDOWS\system32\wbem\ Rename Repository to Repository.old Locate a Repository.xxx folder from a date before WMI was broken and rename to Repository. Reboot Server