简体   繁体   中英

PowerShell Remote from VSTS Pipeline

I'd like to invoke PowerShell commands on my VM remotely. I added "Run PowerShell on Target Machines" task in my pipeline. I provided: IP, username and password of my remote VM. Here's the error that I'm getting:

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.'

On my remote VM, I did:

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

These commands were mentioned here: https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_remote_troubleshooting?view=powershell-6

What else can I do?

To run the PowerShell scripts on the Target Machine Task through WinRM, the Windows Machine, you need to configure the WinRM in the target machine first. There are two protocols for you: HTTP and HTTPS. The HTTPS is more safe and recommended. If you use the HTTPS, then you need to open port 5986 in the firewall and install a self-signed certificate. You can follow the steps in PowerShell on Target Machines task .

For your issue in the comment, you can find the description in Test Certificate and I think the reason is that you use a self-certificate which you create.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM