I want to disconnect from a remote powershell connected to office365 and connect back later.
Tried the Disconnect-PSSession command but it throws error.
$UserCredential = Get-Credential
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.compliance.protection.outlook.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection
.
.
.
.
Disconnect-PSSession $Session
(It redirects to https://nam04b.ps.compliance.protection.outlook.com/powershell-liveid?PSVersion=4.0)
The output I am seeing is:
disconnect-pssession : Disconnect-PSSession operation failed for runspace Id = 613e8071-b691-4365-84dc-2d65c21ea2fa
for the following reason: The disconnection operation is not supported on the remote computer. To support
disconnecting, the remote computer must be running Windows PowerShell 3.0 or a later version of Windows PowerShell.
At line:1 char:15
+ get-pssession|disconnect-pssession
+ ~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: ([PSSession]Session1:PSSession) [Disconnect-PSSession], RuntimeExcepti
on
+ FullyQualifiedErrorId : PSSessionDisconnectFailed,Microsoft.PowerShell.Commands.DisconnectPSSessionCommand
Locally I have Powershell version 4 running. And Get-PSSessionConfiguration shows PSVersion 4 at server. Any help appreciated