For PS SSH Remoting, I can't seem to find a non-interactive way to to obtain a session using New-PSSession, which for my command must include -HostName and -SSHTransport:
PS /home/gmonkey/scripts> $session = New-PSSession -HostName windns -Credential $cred -SSHTransport
New-PSSession : Parameter set cannot be resolved using the specified named parameters. One or more parameters issued cannot be used together or an insufficient number of parameters were provided.
At line:1 char:12
+ $session = New-PSSession -HostName windns -Credential $cred -SSHTrans ...
+ CategoryInfo : InvalidArgument: (:) [New-PSSession], ParameterBindingException
+ FullyQualifiedErrorId : AmbiguousParameterSet,Microsoft.PowerShell.Commands.NewPSSessionCommand
You can use -HostName, but not -Credential. The expectation is that you'd use -UserName, and the SSH transport is going to prompt you for your password. That's how SSH works. SSH isn't capable of accepting a PSCredential object, so there's no way to pass a full -Credential to it. That's more a limitation of how SSH is implemented than anything. I'd expect you to use a -KeyFilePath vs. a credential, given that it's SSH. See example 14 in the New-PSSession help...?