$username = "username"
$password = convertto-securestring "*****" -asplaintext -force
$cred = new-object -typename System.Management.Automation.PSCredential -argumentlist $username, $password
$session = New-PSSession -computername 'testserver' -credential $cred
Invoke-Command -Session $session -ScriptBlock {New-NetIPAddress -IPAddress 10.201.10.10 -InterfaceAlias 'LoadBalancer' -AddressFamily IPv4 -PrefixLength 24}
Remove-PSSession -Session $session
Above script runs fine from VMM server but it fails when I include it as a part of site recovery plan.
Error Message from Azure: Script exception: Cannot validate argument on parameter 'Session'. The argument is null or empty. Supply an argument that is not null or empty and then try the command again.
Where am I going wrong?