Hello,
I want to use the cmdlet "Get-PsSession -ComputerName" and "Enter-PsSession -ComputerName" to get and join a remote powershell session which connects my Windows server 2008 R2 to Microsoft Exchange server.
Well, i previously opened a "New-PsSession" to Microsoft Exchange with the method described in the online technet documentation (and this is working well)
$mycreds = New-Object system.Management.Automation.PSCredential("userlogin@mydomain.onmicrosoft.com", $passwordSecure)
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "https://ps.outlook.com/powershell/"
-Credential $mycreds -Authentication Basic -AllowRedirection -Name $sessionName
ComputerName : pod*****h.outlook.com
ConfigurationName : Microsoft.Exchange
InstanceId : 7fe3********0578c3
Id : 1
Name : mh*****bc1p6
Availability : Available
ApplicationPrivateData : {SupportedVersions, ImplicitRemoting, PSVersionTable}
Runspace : System.Management.Automation.RemoteRunspace
State : Opened
IdleTimeout : 900000
OutputBufferingMode : None
DisconnectedOn :
ExpiresOn :
But when i open a new Powershell window, i try to get the current PsSession this this cmdlet i got an error :
Enter-PSSession -ComputerName pod5****.outlook.com -UseSSL
(i think i need to use SSL because the connection URI ishttps://ps.outlook.com/powershell/,
am i true?)
Error:
Connect-PSSession : The remote session query failed for pod5******.outlook.com 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.
At line:1 char:1
+ Connect-PSSession -ComputerName po******sh.outlook.com -UseSSL
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Manageme...nConnectionInfo:WSManConnectionInfo) [Connect-PSSes
sion], RuntimeException
+ FullyQualifiedErrorId : WinRMOperationTimeout,RemotePSSessionQueryFailed,Microsoft.PowerShell.Commands.ConnectPS
SessionCommand
Secondly, i tryed a Test-WSMan cmdlet, but i also got an error :
Test-WSMan -ComputerName pod51031psh.outlook.com
error:
Test-WSMan : <f:WSManFault
xmlns:f="http://schemas.microsoft.com/wbem/wsman/1/wsmanfault"
Code="2150859046" Machine="FT2-AFR-DSYN-01.afr.corp.local"><f: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.
</f:Message></f:WSManFault>
At line:1 char:1
+ Test-WSMan -ComputerName pod51031psh.outlook.com
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (pod51031psh.outlook.com:Strin
g) [Test-WSMan], InvalidOperationException
+ FullyQualifiedErrorId : WsManError,Microsoft.WSMan.Management.TestWSManC
ommand
Why this error is happening ?
What can i do to join the existant PsSession ?
Does something need to be unlocked by Microsoft?
Is there another way in powershell to re-use an etablished connexion to Exchange?
I hope you can help me, i really need some
Vincent Nunnari