【发布时间】:2023-04-01 03:55:02
【问题描述】:
我已经配置了 winrm。
运行winrm quickconfig 后我得到以下响应,因为 winrm 服务已经在运行。
WinRM service is already running on this machine.
WinRM is already set up for remote management on this computer.
另外,
如果我愿意New-PSSession -ComputerName DESKTOP-0DNHIDE
我的输出低于输出
Id Name ComputerName ComputerType State ConfigurationName Availability
-- ---- ------------ ------------ ----- ----------------- ------------
5 WinRM5 DESKTOP-0DNHIDE RemoteMachine Opened Microsoft.PowerShell Available
我也可以使用
建立 PSConnection`Enter-PSSession -Computername DESKTOP-0DNHIDE`
但是当我尝试使用 Azure Devops Pipeline 部署 CSharp 应用程序时仍然出现以下错误
[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.
我在 azure devops 管道中使用 WinRM - IIS Web App Deployment 任务在本地 IIS 服务器上部署 CSharp 应用程序。
已为我的本地计算机配置了 AzureDevops 代理。
发布管道的完整日志如下:
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
【问题讨论】:
-
默认 WinRM 依赖于 http/https 即分别为 5985/5986 端口。你也打开了这些端口吗?
-
是的,端口 5985/5986 已启用。我可以使用命令
netstat -a -n看到它们 -
您介意在本地和远程计算机上运行
Enable-PSRemoting -Force,然后重试该任务吗? -
@MerlinLiang-MSFT :是的,我已经运行了
Enable-PSRemoting -force和winrm quickconfig。目标机器是我的本地 windows10 机器。我已经为本地机器配置了 AzureDevops 代理。我仍然遇到同样的错误 -
您是否检查了此 CVE 更新:devblogs.microsoft.com/powershell/…
标签: powershell azure-devops remote-access winrm azure-devops-extensions