Azure automation runbook was not working with remote PS, please find the below code for reference,
$Vm = "https://X.X.X.X:5986/WSMAN"
$so = New-PSSessionOption -SkipCACheck -SkipCNCheck
$rmSession = New-PSSession -ConnectionUri $Vm -SessionOption $so -CertificateThumbprint XXXXXXXXXXXXXXXXXXXXXXXXXXXXX
[X.X.X.X] Connecting to remote server X.X.X.X 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.
I have uploaded the required certificate under the automation account too, The same code was working from my local machine.
It would be great if any solution is provided here.
Note: This was not a Hybrid Runbook