azure - 来自 VSTS 管道的 PowerShell 远程

标签 azure powershell azure-devops azure-pipelines

我想在我的虚拟机上远程调用 PowerShell 命令。 我在管道中添加了“在目标计算机上运行 PowerShell”任务。我提供了:我的远程虚拟机的 IP、用户名和密码。 这是我收到的错误:

Unable to create pssession. Error: 'Connecting to remote server failed with the following error message : WinRM cannot complete the operation. Verify that the specified computer name is valid, that the computer is accessible over the network, and that a firewall exception for the WinRM service is enabled and allows access from this computer. By default, the WinRM firewall exception for public profiles limits access to remote computers within the same local subnet. For more information, see the about_Remote_Troubleshooting Help topic.'

在我的远程虚拟机上,我做了:

Enable-PSRemoting
Set-NetFirewallRule -Name "WINRM-HTTP-In-TCP-PUBLIC" -RemoteAddress Any

此处提到了这些命令:https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_remote_troubleshooting?view=powershell-6

我还能做什么?

最佳答案

要通过 WinRM(Windows 计算机)在目标计算机任务上运行 PowerShell 脚本,您需要首先在目标计算机中配置 WinRM。有两种协议(protocol)适合您:HTTP 和 HTTPS。 HTTPS 更安全,推荐使用。如果您使用 HTTPS,则需要在防火墙中打开端口 5986 并安装自签名证书。您可以按照PowerShell on Target Machines task中的步骤操作。

对于评论中您的问题,您可以在测试证书中找到描述,我认为原因是您使用了您创建的 self 证书。

关于azure - 来自 VSTS 管道的 PowerShell 远程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56441174/

相关文章:

azure - Windows Azure 网站状态受限

django - Azure Devops 将 django 应用程序部署到 Linux Azure 应用服务

windows - 用于安装字体系列的 Powershell 脚本

git - Azure 管道子模块克隆失败

azure - 使用 Azure Devops 创建 Azure 静态 Web 应用程序时,没有可见组织

node.js - 如何使用 Node.js 从 Azure 表存储获取表列表?

Azure API 管理 + Azure Function 和托管标识

azure - 无法在浏览器中访问Neo4j社区版(安装在Azure中的Linux虚拟机上)

multithreading - Powershell 运行空间和颜色输出

powershell - 新对象 PSCredential 不起作用 - 在句法上使用 Unicode 标点符号