Hello all
I've added all the IP range listed in https://devblogs.microsoft.com/devops/new-ip-firewall-rules-for-azure-devops/ into my firewall. But still im not able to run powershell command from azure devops pipeline YAML to my on-premises windows server. Every time im getting new IP from microsoft, and that are not listed in above mentioned site.
Im able to connect to server with my local machine using below powershell command
below is my yaml pipeline script
pool:
vmImage: 'windows-latest'
stages:
- stage: 'Deploy'
jobs:
- deployment: 'Deploy'
environment: 'stage'
strategy:
runOnce:
deploy:
steps:
- task: PowerShell@2
inputs:
targetType: 'inline'
script: |
$so = New-PsSessionOption –SkipCACheck -SkipCNCheck
$username='myUserName'
$password='myPassword'
$secpasswd = ConvertTo-SecureString $password -AsPlainText -Force
$credentials = New-Object System.Management.Automation.PSCredential($username, $secpasswd)
Enter-PSSession -ComputerName xyz.com -Credential $credentials -UseSSL -SessionOption $so
write-output 'host name is '+$(hostname)
Im getting error :
Enter-PSSession : Connecting to remote server xyz.com 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.
Is it issue releated to firewall or my approach is wrong to execute Powershell script using azure devops?