Remote Powershell through a Load Balancer
- When trying to create a remote powershell session using "New-PSSession", if not specified otherwise the default authentication method would be Kerberos. However if you are going through a load balancer or connecting to a alias hostname you may not have the appropriate configuration to use Kerberos authentication (SPNs, Delegation, etc.).
- You can always prompt a user for the credentials and pass them to "New-PSSession" but if you are running a non-interactive script you may want to pass the credentials of the user or account that the script is running as which leaves you with Negotiate authentication. Specifically "NetgotiateWithImplicitCredential" is the required authentication method
- The sample below will create a new session using Negotiate authentication and then import the session. The "$tmp_null" variable and "-DisableNameChecking" parameter are only there to quiet down some of the warnings and other noise that may appear on the screen.
$session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://host.domain.com/PowerShell -Authentication NegotiateWithImplicitCredential $tmp_null = Import-PSSession -Session $session -DisableNameChecking