I am currently working on a script that connects to our mailserver and purges a specific folder in a mailbox, I got everything working without a problem except the connecting to the server. When I tried this morning it worked without an issue. But if i Try now i get
The WinRM service cannot process the request because the request needs to be sent to a different machine. Use the redirect information to send the request to a new machine. Redirect location reported: h
ttps://mail.mailserver.se/owa/PowerShell . To automatically connect to the redirected URI, verify the "MaximumConnectionRedirectionCount" property of the session preference variable "PSSessionOption", and use the "AllowRedirection" p
arameter on the cmdlet.
At line:5 char:12
+ $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri ht ...
When I try to use https://mail.mailserver.se/Owa/PowerShell it spits out:
New-PSSession : [mail.mailserver.se] Connecting to remote server mail.bluestep.se failed with the following error message : WinRM cannot process the request. The following error occurred while using Kerberos
authentication: The computer mail.bluestep.se is unknown to Kerberos. Verify that the computer exists on the network, that the name provided is spelled correctly, and that the Kerberos configuration for a
ccessing the computer is correct. The most common Kerberos configuration issue is that an SPN with the format HTTP/mail.mailserver.se is not configured for the target. If Kerberos is not required, specify th
e Negotiate authentication mechanism and resubmit the operation. For more information, see the about_Remote_Troubleshooting Help topic.
Here is the part of the connection part of the code.
$password = "MyPasswordHere"
$UserName = "domain\username"
$Credentials = New-Object System.Management.Automation.PSCredential("domain\username", $password)
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://Mailserver/PowerShell/ -Authentication Kerberos -Credential $Credentials
Import-PSSession $Session -AllowClobber
Pardon if i missed something or if this is unclear.